This tutorial shows how to deploy an ASP.NET web application to an Azure Web Site by using Visual Studio 2013.
With the release of new Windows Azure SDK version 2.2 for Visual Studio 2013, sign in has been integrated directly within Visual Studio so that you can sign in to Windows Azure without ever leaving the IDE. This is great for developers as they now develop, debug and manage Windows Azure resouces from within Visual Studio. You no longer need to create and download the management certificates. One of the new feature is Remote Debugging, devlopers can now attach the debugger to running instance of Windows Azure cloud service right within Visual Studio. Remote debugging is great feature for developers as they can now debug a live cloud service which is very helpful if you want to track down any issues.
I believe you already has a Azure account as this is the prerequisite for this tutorial. If you don't have one please check here how to get one.
If you are following the previous tutorials then you must have development environment setup either for visual studio 2013 or 2012/2010. If not, setup the development environment by installing Azure SDK and other related tools - refer previous tutorial here to get more details about how to setup dev environment for Azure development.
Create a web application
1. Open Visual Studio 2013.
2. Go to File menu and then New -> Project. In the new project dialog box, expand Visual C# and select Web under Installed Template, and then select ASP.NET Web Application. Ensure that .NET Framework 4.5 is selected as the target framework.
With the release of new Windows Azure SDK version 2.2 for Visual Studio 2013, sign in has been integrated directly within Visual Studio so that you can sign in to Windows Azure without ever leaving the IDE. This is great for developers as they now develop, debug and manage Windows Azure resouces from within Visual Studio. You no longer need to create and download the management certificates. One of the new feature is Remote Debugging, devlopers can now attach the debugger to running instance of Windows Azure cloud service right within Visual Studio. Remote debugging is great feature for developers as they can now debug a live cloud service which is very helpful if you want to track down any issues.
I believe you already has a Azure account as this is the prerequisite for this tutorial. If you don't have one please check here how to get one.
If you are following the previous tutorials then you must have development environment setup either for visual studio 2013 or 2012/2010. If not, setup the development environment by installing Azure SDK and other related tools - refer previous tutorial here to get more details about how to setup dev environment for Azure development.
1. Open Visual Studio 2013.
2. Go to File menu and then New -> Project. In the new project dialog box, expand Visual C# and select Web under Installed Template, and then select ASP.NET Web Application. Ensure that .NET Framework 4.5 is selected as the target framework.
3. In the New ASP.NET Project dialog box, select the MVC template, and then click Change Authentication.
4. Since this is sample application, we don't need any login. In the Change Authentication dialog box, click No Authentication, and then click OK.
5. If you haven't already signed in to Azure, Visual Studio prompts you to do so. Click Sign In.
6. Enter the ID and password of the account that you use to manage your Azure subscription.
7. When you're signed in, the Configure Azure Site Settings dialog box asks you what resources you want to create. Visual Studio provides a default Site name, which Azure will use as the prefix for your application's URL. If you prefer, enter a different site name.In the Region drop-down list, choose the location that is closest to you. This setting specifies which Azure data center your web site will run in.Leave the database fields unchanged as for this tutorial we are not using any database. Click OK.
8. In a few seconds, Visual Studio creates the web project in the folder you specified, and it creates the web site in the Azure region you specified. You will get a message that your project has been created. The Web Publish Activity window shows that the site has been created.
9. If you go to the Windows Azure Management Portal, you can see the website listed under Web Sites tab.
Though your website has been created, there are no contents yet. We need to deploy the site.
Deploy the application to Azure
1. In the Web Publish Activity window, click Publish WebApplication1 to this site now. Publish Web wizard will appears. The wizard creates a new publish profile that contains settings such as the web site URL that Visual Studio needs in order to deploy your project to Azure. The profile is automatically saved so that later when you make changes to the project you can easily redeploy the project to the same site.
2. In the Connection tab of the Publish Web wizard, let the Publish method as Web Deploy. Change the password if you wish and click on Validate Connection to make sure that Visual Studio can connect to Azure in order to deploy the web project.
3. When the connection has been validated, a green check mark is shown next to the Validate Connection button.Click on Next button.
4. In the setting tab, you can accept the default settings on this tab. You're deploying a Release build and you don't need to delete files at the destination server, precompile the application, or exclude files in the App_Data folder. Click on Next button.
5. In the Preview tab, click Start Preview. The tab displays a list of the files that will be copied to the server. You can also skip this step and directly click on Publish button.
6. Click on Publish Button. Visual Studio begins the process of copying the files to the Azure server. The Output and Web Publish Activity windows show what deployment actions were taken and report successful completion of the deployment.
7. Upon successful deployment, the default browser automatically opens to the URL of the deployed web site, and the application that you created is now running in the cloud. The URL in the browser address bar shows that the site is being loaded from the Internet.
How to redploy after making changes
1. Modified any file you want or add a new one.
2. In Solution Explorer, right-click the project, and choose Publish.
3. The Preview tab of the Publish Web wizard appears. If you needed to change any publish settings you could choose a different tab, but now all you want to do is redeploy with the same settings. Click on Publish button.
4. Visual Studio deploys the project to Azure and opens the site in the default browser.
There also a tool called Web One Click Publish tool, which is a quicker way to redploy. This toolbar is not enabled by default. To enable it go to Views-> Toolbars-> Web One Click Publish. You can use it to select a profile, click a button to publish, or click a button to open the Publish Web wizard.
In this tutorial we have seen how we can use the integrated sign-in feature of Visual Stdio 2013 and deploy the application to Windows Azure. In the upcoming chapters we will learn more features of Visual Studio like remote debugging.