Create new ASP.NET 5 project for existing Azure App Service - asp.net

I've finally gotten around to familiarizing myself with Azure. I've created several App Services on a new App Service Plan. I've created a SQL Server instance and a SQL Server DB. My intention is to create new MVC sites, one for each App Service I created. I got the Azure SDK all set up and went about trying to create my first site, but now I'm stuck. It seems Microsoft expected me to create the projects in Visual Studio first, and allow the Azure SDK to create a corresponding App Service in Azure for the new projects. This isn't what I've done. So, I've encountered a screen where Visual Studio is asking me to put in details (Web App Name, Resource Group, App Service Plan) for the new App Service, but it doesn't let me choose from a list of existing App Services.
How can I associate the project I'm creating in Visual Studio with the existing App Service I already created in the Azure Portal?
This is the dialog I encountered while creating a new Web Application in Visual Studio and selecting the option to host in Azure. Notice there's a text box to enter a new App Service (Web App) name, but no drop-down to select previously existing App Services.

Azure Web Apps can be created in either direction. You should be able to create them either via Visual Studio or directly in the Azure Portal.
I'm assuming that you've already performed the following steps:
In Solution Explorer, right-click web app project.
In popup menu, select "Publish"
Select Azure subscription to see if any Web Apps exist.
From here on forward, you should be able to create a new Web App or select an existing Web App. Since you're not seeing your existing Web App, let's try to troubleshoot.
In the Publish dialog, create a new Web App (in Visual Studio).
In the Azure Portal, check to see if that Web App was created.
In case you have more than 1 subscription (e.g. free, BizSpark, MSDN from work), this will confirm whether you're looking at the same subscription in both places.
I've included a screenshot below to show you that I have multiple subscriptions, each of which contains a different set of Web Apps.
Hope that helps!

Related

Migrating ASp.net webform based websites to Microsoft Azure

I have to migrate asp.net webform & asp.net MVC websites to Microsoft Azure and most of the webform based website have been created as "website project" in visual studio. and all website use MS SQL Server 2008 R2 as database plus all website use either .net Framework 4.0/4.5.
I confused by reading article regarding migrating webform based website to Azure not working and need code changes and if we use Azure database then we cant use stored procedures etc... this has confused me alot.
So i have few question regarding this.
Can i move asp.net webform 4.0 based website directly to Azure without making any code changes assuming we are connecting to external SQL SERVER 2008.
For first step can which MS SQL Server database i need to choose on Azure so that i can easily restore database in Azure and connect to this database from my local machine using MS Management Studio..
I have heard lot about Azure store files as blob and we need to make change to code to point to new path. What is this Azure blob and why do we need to change code for pointing them blob.
What i have to do keep allowing users from uploading images & document without making any changes in the code..
Does Azure website have always 1 instance running or multiple instance running, i am asking this as our website use InProc session state will i lose session if it is ruuning on multiple instance. or should we prefer SQL Session state in Azure enviroment.
What i should take into consideration for migration current website to Azure.
Will copy pasting all the files in Azure work. Please advise
Depending on how old the ASP.NET webforms projects are, you are going to need to bring them up to date with current security, and anti forgery tokens, etc.
Also if the project was previously a "Website" and not a "Web Application", this is also something that you will need to take into consideration!
I am currently working on upgrading a website to a web application.
This might be a useful website to look through
http://www.gregthatcher.com/Azure/Ch7_ConvertWebsiteToWebApplication.aspx
Migrating to Azure is easy ,
create a Azure account and create the web app which you want to host or create.
you can deploy using FTP or use the build and deploy feature in TFS account.
Steps
You need to create web app in your account.
create a DB in azure manually or export your DB to azure from Management studio if you have an existing DB
get the Connection string from the Publish profile from Azure.
Setup the storage account if you want to store files ,images etc.

Web App and Database Host on Azure

Hy Guys,
I'm new to Asp.net and Azure. I was working on ASP.NET with the help of this documentation link, When I publish my project on Azure by creating the Web App with latest portal on Azure, but it is only my application host on the Azure. And now i need to publish the my project database to Azure. In the present portal, the database option is not present there when we create the Web App on Azure to host the database as well with the Web project. But in the old portal as the documentation link guides us the database option is also present there when we publish our Web project on Azure.
Can anyone explain me how can i deploy my Web App existing database to Azure even if my Project has been deployed on Azure?
How can I deploy my existing Web App Database to Azure on the new portal.
If you use Code First Model of Entity Framework, you could just configure the connection string for your web application when you publish your web application. Entity Framework will generate tables for you automatically.
If there are existing data in your database which you want to migrate to Azure SQL Database. You could download a tool named Migration Assistant which will help you do it. For detail steps, link below is for your reference.
SQL Server database migration to SQL Database in the cloud
In the documentation he is using the old dashboard of Azure in which database option is attached with the Web App Publish procedure.
A small difference between old dashboard and new dashboard is that the creating Azure SQL Database feature is hidden when you create your app service. You need to click Explorer additional Azure services link to open the a new window for creating Azure SQL Database.
After creating a database, you could choose the database in the Setting tab when you publish your web application.
You also could create a database directly in Azure portal. After creating a database, you could get the connection string from the overview page.
If you make changes to a database schema and are using code first EF, will EF update your database schema when you redeploy your web app?
It depends whether you have enabled and run the migration. In the publish setting window, we could click the [Execute Code First Migrations] button to update the database schema .
If this button is disabled in the setting window, we need to run Enable-Migrations command in Package Manager Console.
In Visual Studio click menu Tool -> NuGet Package Manager -> Package Manager Console, input Enable-Migrations and run it.

Deploying ASP.NET Core solution with class library to Azure

I'm working in VS2015 and have a ASP.NET Core solution with two projects - an API Web Project and a Class Library that holds all the data entities, context and Entity Framework migrations. The API project references the class library and all works well on my local machine.
I now want to deploy the solution to Azure and this is where I'm hitting the problem. If I right click on the API project and go through the Azure App Service publish wizard, on the Settings tab I expand Databases and the message is "No databases found for this project" - which I'm guessing is because it can't find a context as it's not in this project.
If I do the same on the CL project though, there is no Azure App Service deployment option, the only option is File System and clearly there's no option to create the database there either.
So, in summary, my question is how I can deploy this type of solution to Azure and have the database created and migrations applied?
I think you need to create the DB first in the azure and then try to publish your application through the wizard. The database is on your local machine and the application will work just fine on your local environment. But on the cloud you have to first create the database on Azure SQL. Then you need to get the SQL connection string from the portal and update your config file accordingly. Once this is done you can then publish your application from Visual Studio. Please note that the wizard will still not show you the databases, but the application, when configured properly will run fine.

ASP.Net Core - Applying updates to an already published Azure Web App

I published my first ASP.Net Core project as an Azure Web App using Visual Studio 2015. It has a SQL database component.
I then modified the web app locally and tried to publish again and was given an error about a database not being able to be created. It seems that publishing changes with the same settings was attempting to recreate the existing database.
I followed the publishing instructions from the official docs here:
https://docs.asp.net/en/latest/tutorials/publish-to-azure-webapp-using-vs.html
The above instructions don't include what to do when one wants to push an update to an already published web app. However I was successfully able to publish an update by going into settings in the publish window and unchecking "Apply Migration on Publish".
What do I need to do if I make changes to the database structure itself (tables/columns/etc). How can I successfully publish this? The documentation seems sparse regarding this.
Thanks for any assistance.

Deploy the default MVC 4 template to windows Azure

I am very new to Windows Azure and am tinkering with it to learn how it works. To keep things as simple as possible, I am trying to deploy the default MVC 4 template that is generated by VS 2012 Express for web. I created a new project - an Azure cloud service. I selected an MVC 4 web role. And that creates a nice little asp.net application with home, about and contact pages, and links to register and login. I just want to deploy this site to Azure and see it work on the cloud.
However the membership does not appear to work on azure. The pages of the application appear correct. However when I click the 'Register' link it does not take me to a page to nter a new username and password. I do not believe the membership tables are being generated anywhere either.
Considering how simple this is, I think I must be making a silly mistake somewhere. I would really appreciate if someone could help me with this.
Also, for the record, I have noticed that if I create a stand alone MVC 4 project in VS2012 Express (as opposed to a Windows Azure Cloud service project with an mvc 4 web role) then when I right click that MVC4 project and choose to publish it, it allows me to specify a sql database using a connection string. What is more is once it is published to Azure, the membership works perfectly. I can create useraccounts and log in. If I examine my SQL Azure database using the azure portal, I can see the new membership tables created there.
But when I try to publish a Windows Azure Cloud service with MVC4 webrole, I do not see any option to provide a connection string of any sort to the azure project. Maybe that is why the membership is not working... since there is no database linked with the web role... but I cannot figure out how to specify this. I was under the impression that publishing a stand alone MVC4 project to Azure, and publishing an Azure Cloud Service with an MVC4 Web Role is the exact same thing, please correct me if I am wrong. And either way, I should be able to see the membership functionality of my mvc 4 web role.
Here are the steps to recreate what I have. Basically it is all default stuff:
Create a new project in VS2012 Express
File -> New Project -> 'Windows Azure Cloud Service'.
On the next screen add an ASP.NET MVC 4 Web Role to it.
On the subsequent screen choose 'Internet Application'.
These 3 steps create a new project. It runs locally just fine.
Now I try to put it on the cloud.
Right click on the windows azure project in solution explorer and choose 'Publish'.
Choose the subscription (I already have certificate/credentials in place to publish to azure from VS so I select that)
Create a cloud service on the next screen (I name it 'garyazurecloudservice').
Accept all the default settings in the Publish wizard and click Publish.
The publishing process takes a few minutes.
The web application can be viewed at http://garyazurecloudservice.cloudapp.net/.
The Home, About and Contact pages all display correctly. However it I click the 'Register' link at the top right I see a webpage with the correct layout template, but an error in red that says:
"Error. An error occurred while processing your request."
I have tried to create an SQL database on Azure but I don't see any way to connect this role to it. Possibly that is the problem? Or maybe it is something else altogether. I would appreciate if anyone can tell me what is wrong.
I have spent the entire day googling and going in circles with no success. Thank you for any help you can provide.
Gary
You're right in that the Membership section of your website would not be able to create the SQL tables in the background when running on Azure, due only the problem of where those tables would reside.
Remember, that Azure hosting space is different from traditional hosting, in that your site would exist on a virtual machine, with files being replicated to another virtual machine if the first were to experience problems. Also, what would happen if you were to invoke a second 'server' to host your website, to cater for a load, perhaps? Where would the tables live then, and how would the second virtual machine know how to access the first?
The answer would be to create a SQL Azure database, upload your tables there, and then you'd have a permanent place for 1, 2 or 1000 'servers' that are running your website to access a central database repository of your data.
I know in your example, it should just 'work' and I agree to some extent, but your application running on your local machine or with your existing (traditional) web host is quite different to the Azure model of working.
In terms of your question regarding how the SQL Azure set-up works, presumably you've created this through the Portal, via the www.windowsazure.com website? If so, then you should be able to see and manage your SQL Azure database from there, including gaining access to the Connection Strings section, whereby you would copy and paste these into your web.config file for your MVC4 application. From there, you can utilise this database pretty much as though you would any other.
I hope this all helps - Azure is a beautiful beast once tamed.

Resources