Create & publish Web App from Visual Studio



Overview of Web App in Visual Studio

There are several ways to create a web app by using Visual Studio.

  • Server Explorer to create a web app produces a web app environment to which you can publish a web application later.
  • ASP.NET Web Application template. With the Azure SDK Tools installed, this template also enables you to target Web Apps or Virtual Machines when hosting in Azure.

Create a Web App using Server Explorer

The Server Explorer window in Visual Studio brings certain management capabilities directly into your Visual Studio environment. If Server Explorer is not visible, you can open it from the main menu by selecting View > Server Explorer.

To use the Server Explorer with your Azure Subscription, you must first connect it to your Azure Subscription. Do this by right-clicking the Azure icon and selecting the option to Connect To Microsoft Azure Subscription.

Server Explorer - Azure Subsciption

After successfully authenticating, the Azure node in Server Explorer will display resources from each of your Azure Subscriptions.

If you have multiple subscriptions associated with your account, then you may want to filter the resources shown in the Azure node to a single subscription with which you are working. You can do this by right-clicking the Azure node in Server Explorer and selecting the option to Manage Subscriptions. This opens a dialogue where you can select the subscriptions and regions for which you want to filter Server Explorer’s user interface

Manage Azure Subsciptions

To create a new web app and, optionally, a SQL database using Server Explorer, right-click the App Service node and select the option Create New Site. This will open a single page dialog where you can specify settings for the web app.

Create Web App - Server Explorer

Because there are few options for configuring the web app and SQL database, you should expect some limitations when taking this approach.

Some of these limitations are as follows:

  • For the App Service Plan, you have the option to select an existing plan or to specify the name to create a new plan. If you choose to create a new plan, the pricing tier will default to F1 Free. You later can change this to a pricing tier appropriate for your needs.
  • Although you have the option to specify the Database Server name or select an existing server, the name of the SQL database will be set for you and defaults to <web app name>_db. This cannot be changed.
  • You cannot specify the tier for your SQL database if you choose to create one. You later can change this to an appropriate tier.
  • It is assumed that if you want a database, you want an Azure SQL database. In other words, there is not an option to select a MySQL database. You would need to use the Azure portal if you want a MySQL database.

Create a Web App using the ASP .NET Web Aplication template

To begin, from the Visual Studio main menu select File > New > Project. In the New Project dialog, expand the Templates node on the left and click the Cloud node to view the available cloud templates. From the list of templates, select the ASP.NET Web Application template.

Create Web App - Asp.NET Template

If you select the option for Application Insights (on th right), then code and configuration are added to the project to capture telemetry data. Application Insights can be added to a web app later, so unchecking it does not prevent you from taking advantage of this feature later.

On the next page in the New Project Wizard, you can select from the many ASP.NET project templates, such as the MVC template. With the Azure SDK Tools installed, the wizard allows you to change the authentication and Azure hosting options.

Create Web App - Asp.NET MVC Template

The authentication option defaults to Individual User Accounts, but you can change this by clicking the Change Authentication button. The authentication options are as follows:

  • No Authentication For applications that do not require users to sign in.
  • Individual User Accounts For applications that will store user profiles in a SQL database.
  • Work And School Accounts For applications that will authenticate users against Active Directory, Azure Active Directory, or Office 365. Choosing this option enables you to specify the domain name for the organization and directory access permissions.
  • Windows Authentication For applications running in a traditional intranet environment.

Selecting the option to Host In The Cloud using Microsoft Azure enables you to host your application using a Microsoft Azure Web App or Microsoft Azure Virtual Machine. After completing the New Project Wizard, you will have a fully functioning ASP.NET MVC application that you can run locally. If you selected the option to Host In The Cloud with Azure Web Apps, then your web app environment also has been created in Azure and your solution has the information it needs to publish the application to that web app environment.

Publish from Visual Studio

When you are ready to publish the application, right-click the ASP.NET project in Solution Explorer and select the Publish option. Alternatively, you can select Build > Publish <your project name>> from the main menu.


PROMOTIONS