The final step when developing with ASP.NET would be to deploy your website to a live Web Server. For this lesson, we’re going to use the Web Apps portion of Microsoft Azure App Services and deploy the application using Visual Studio tools. It will be deployed to a remote Virtual Machine that Microsoft configures and manages for you. This approach is a lot more hands-off then the typical deployment to a Web Server, where you are expected to manage and support the server along with the application that runs on it. This option describes the “PaaS” model which stands for “Platform as a Service.” However, you do have the option for a more hands-on approach with the “IaaS” model, or “Infrastructure as a Service” in which Microsoft will set up the operating system and leave the rest up to you. We’re choosing to go the PaaS route because it removes a lot of the headache involved with managing a website in exchange for losing control over underlying configurations that are not necessary to have access to in 99% of cases. You might require access to unique server configurations if you are running uncommon or legacy services that your application depends upon, but again that is extremely unlikely.
There are a lot of cool things about the Azure platform beyond just making your job easier. Because your site is running on a Virtual Machine it’s easy to modify or make scalable to accommodate increasing demand. For example, you can – with a push of button – increase the running instances of your Web Server.
Go to https://azure.microsoft.com and create an account. We’ll be using dummy account info for this lesson, but you will want to use your own account information on your end. Once you’ve gotten your account information, open up the application we’ve been working on (LocalDbExample) in Visual Studio.
Click on the notifications icon in Visual Studio to check if there are any available updates to the Azure SDK and download them:
In the Solution Explorer, right-click on the main Presentation layer and select “Publish” from the menu that appears:
Select the “Microsoft Azure Web Apps” option from the publishing dialogue that opens. Afterwards, you will be prompted to sign-in with your account credentials:
After you’ve signed-in, you will be prompted to create a new Web App:
In the following dialogue, set up your Web App with unique values, following a similar pattern to what you see here:
After clicking “Create”, you’ll want to choose “Web Deploy,” keeping the other default server details, and then click “Validate Connection”:
At the next dialog, make the following selections:
Also, specify the database to run on the remote server and then click “Next”:
Note that the database schema and configuration details will transfer to the remote server, however your existing database entries will not. You can click on “Configure database updates” in the dialogue above and it will let you run an SQL command to import your existing database values.
Finally, after all of that you can click on “Publish” and it should launch your browser pointing to your website running on the remote URL:
You can make changes to the remote database from within Visual Studio by opening the Server Explorer:
View > Server Explorer
And from the Server Explorer right-click on the remote database and select “Open in SQL Server Object Explorer:”
You will be prompted to add a firewall rule to allow remote access from your computer and after that you should be able to peruse through the remote database locally:
If you want to share your project, it’s important to first delete the “PublishProfiles” folder in the main project under the Solution Explorer. This folder contains sensitive data relating to your Microsoft Azure account that can potentially let others take control of it.
If you want to learn more about Azure, you can take the free course on Microsoft Virtual Academy:
Lesson 70 - Deploying the App to Microsoft Azure Web Services Web Apps