Demo: Create an ASP.NET website in Visual Studio and deploy it as a web app
To perform
this tutorial, you must have Visual Studio 2013 or Visual Studio 2015 installed
and the most recent version of the Azure Tools and SDK.
Create a
new web application with Visual Studio by following these steps:
1.
Open Visual
Studio. Select File > New > Project.
2. Select ASP.NET Web Application;
the dialog box for creating a project appears, as shown in Figure 2-16. On the
right side of the dialog box, clear the Add Application Insights To Project
check box. This will prevent the creation of a separate Application Insights
instance for this web application.
4. When prompted to select the type
of ASP.NET application to create, select MVC from the list of ASP.NET
Templates, as shown in Figure 2-17. Clear the Host In The Cloud check box. You
will set that up separately. Click OK to continue.
5.
Visual Studio
will create a basic ASP.NET MVC application that runs “as is.” You can modify
it later to make it your own.
6. Now, publish this web application
to an App Service in Azure and assign it to the App Service plan created
earlier in this chapter. You will create the App Service when you publish the
web app the first time. Right-click the website and select Publish (Figure
2-18).
7. The Publish Web dialog box will
be displayed. Select the Microsoft Azure App Service (Figure 2-19).
Figure
2-19 Select the Microsoft Azure App Service for the publish target.
8. You will be prompted for your
subscription name. You may be prompted again to enter the credentials for your
Azure subscription. If the correct account is not displayed, click it to show a
drop-down list and add an account if necessary. When the correct
account is
selected, select the Subscription and be sure the View is set to Resource
Group. Open the Resource Group, and you will see the resources that have been
set up already. In Figure 2-20, you can see the web apps that I have already
created. To publish this application to a new web app, click New.
Figure
2-20 Make sure the right account and subscription are selected; show the
resources by group.
9. The Create App Service dialog box
(Figure 2-21) appears next. Remember that an App Service is simply the host for
a Web App, Mobile App, Logic App, API App, or Function App. You’ll create a new
App Service to host your MVC web application here.
Set the Web App Name. This will be used for the URL for the web
app, so select it wisely.
Select the Subscription.
Select the Resource Group. If you use the one you created at the
beginning of this chapter, then when you’re done, you can delete that Resource
Group and all of your resources will be removed.
Last, select the
App Service plan that you created earlier in this chapter. This application
will be hosted on the same VMs as the other web app(s) you have placed in that
plan.
Click
Create to create the App Service.
If you
look in the Azure portal now, you will see your App Service has been created.
10. Now let’s use Web Deploy to
publish our web app to our app service. After creating the app service, the
Publish Web dialog box will be displayed (Figure 2-22). You can use the default
values.
Figure
2-22 Publish settings for the MVC application.
11. Click Validate Connection to make
sure the information is correct. After it validates, click Next to go to the
next dialog box (Figure 2-23).
12. This dialog box lets you set the
Configuration to Debug or Release and provide a connection string to a database
if needed. Note that if you are going to use remote debugging on your web app,
you will want to select the Debug configuration. Click Next to reach the final
page (Figure 2-24).
13. You can preview your site here.
When you’re finished, click Publish to deploy the web application to the App
Service. It will open your web application in the default browser after it is
published.
When you make changes to your website, you can go
through this same process to publish the website again. Note that it will only
publish the files that have been added or modified.




