If you have never hosted a web site on Azure and need some guidance, you are at the right place. When you have a web application, you can host it in 3 different ways in Azure – as an Azure Web App, as an Azure Cloud Service or inside a Azure Virtual Machine. In this post, I am going to cover Azure Web App.
An Azure Web App is a fully managed environment available in Azure for hosting web sites and web applications quickly. Previously, this service was called as Azure Website. Now, it is part of the bigger offering called Azure app service.
In this post, I am going to show you how you can host your first web application in Azure. Before getting started, please note that I am using Visual Studio 2015 Update 3 for the demo. You should also have an active Azure subscription.
Here are the steps for hosting your first website as Azure Web App:
- Go to Visual Studio and create a new project. Chose Web and select ASP.Net web application. Give a name of your choice to the project. You can also chose to select Application Insights which is a telemetry service. Then click OK:
- Select MVC and leave the checkbox for Host in the cloud as unchecked. Then, click OK (If you are creating Azure Mobile app or Azure API app, these go under the same Azure App service, under which web apps are included:
- Once your project is ready, build it and test it locally.
- Go to Visual Studio and right click the project and click on Publish:
- Ensure that you have logged into Visual Studio using the Live/Hotmail/Outlook ID linked to your azure subscription. It will automatically give you options to host the web app under your subscription.If you need help on how to do that, please refer this post. Once you click on Publish, the publish window opens up as below:
- Click on Microsoft Azure App Service, it will open up the following window:
- Select the appropriate subscription and click on New, if you would like to create a new app service. You can also choose from the list of existing app services from the list displayed.
- Once your app service is ready, validate the Connection settings and click next:
- Verify the app settings including the connection strings for your app service. In my demo, I dont need a connection string. Click on next:
- On the preview tab, click on Publish to publish the web app in Azure as App Service:
- Monitor the status of the Publish operation in the output window.
- Once it says, Publish succeeded, Visual Studio will automatically open the Azure hosted website in browser. If it doesn’t, copy the URL you have specified during publish process and paste it in the browser to access the website.
- Notice the URL of the website. It would be *.azurewebsites.net and your website is now hosted and accessible over Internet.
- Login into the Azure portal with your Live ID and you should be able to see a new Azure Web App created under your subscription.