888-682-5765 info@totalsol.com

Introduction

In this introduction to setting up an application for Azure App Service, we walk you through how easy it can be to get started with Azure. Firstly, we will demonstrate the basic information and steps required to set up Azure App Service Resources to host an ASP.NET Web Application. Then, we will configure an example web application to publish to the newly created App Service instance using Visual Studio.

Setting up your application for Azure App Service (for Simple Deployment)

Creating a new Azure Web App through the Azure UI

Start by logging in to Azure, and then choose “Create a resource.” 

Getting Started - Create a resource
Figure 1 – Create a Resource

Choose “Create” next to the “Web App” option on the “Create a Resource” page. 

Create a resource: Choose Create
Figure 2 – Create

This will bring you to the “Create Web App” options setup page.  It should look like the following image. 

Create a Web App: Setup page
Figure 3 – Create Web App Setup Page

After choosing an available subscription you will need to fill out the choices on the Basics properties page to continue.  

Resource Groups 

If this is your first app deployment, then you should create a new Resource Group. This will be the container that holds all the resources that you would want to associate with your application. There is more than one way to use Resource Groups to organize your Resources. Every organization will have a different choice, but the simplest plan may be to create a Resource Group for each application and a different Resource Group for each environment that you want to deploy such as for Dev/Test and Production. This way, you can manage the resource more easily and monitor utilization/billing better.

Create a new resource group and continue. Putting everything in one independent resource group makes it easier to remove them after you finish learning from this example. You can just delete the resource group, and it will remove everything created during this demo/tutorial.

Instance Details

The instance details are the main properties of the Web Application. 

Naming

You need to define a name for the application, which must be unique not just compared to all the applications that your organization has created, but unique to all Microsoft Azure Web Application sites in existence.  The public name format will be [yourname].azurewebsites.net. 

Publishing 

Currently, there are three options to choose from. They are “Code,” “Docker Container” and “Static Web App.” For this exercise, you should choose “Code” as that will allow you to deploy from Visual Studio.

Runtime Options 

The “Runtime Stack” allows you to choose the type of code environment you are looking to deploy your code to. As of the date of this article, you can choose to deploy a .NET Framework, .NET, Go, Java, Node, PHP, or Python application. Subsequently, this will configure the environment to meet the needs of a basic application of the chosen type with properly configured runtimes. Some of the options such as Java have sub-options to choose from that will be familiar to a Java developer. The operating system available is dependent on the coding of choice. For .NET or .NET Framework, you can choose from Linux or Windows. Linux supports all choices, but not all choices support Microsoft Windows. For this exercise, choose .NET 6 and Windows. 

Region 

There are several reasons why Region can be an important choice. For instance, if your organization has a plan in place, you should follow this to create your new web application.  Otherwise, things that can impact your choice are the following: 

  • Where in the world is your business located 
  • Where in the world are your users located 
  • What regions have you used for existing Azure Resources that you may need to utilize in your application 
  • Do you have any existing networking configurations or VPNs setup in Azure 
  • How are you providing backup and recovery of the application 
  • How does your application need to scale as demands change 
  • Is the region that you are deploying to hosted in a country that has the same regulatory requirements as your business and users 
  • Are you comfortable deploying to the region based on its history of natural disasters or other regional issues 

In general, it is good practice to deploy your application to a region closest to the majority of your users. 

Pricing Plans/Resource Size/Hosting costs 

When setting up your new Web App, hosted in Azure, you need to create or utilize an existing Service Plan.  This will control the virtualized hardware resources that are allocated to your web application and determine the cost of using those resources. If you are creating a new Service Plan you will need to create a new name for that plan and then you will have to choose an available Pricing Plan. The general choices are: 

  • Free 
  • Shared 
  • Basic 
  • Standard 
  • Premium 
  • Isolated  

Free and Shared can be good for applications that are not business-critical. For most business applications you should choose a plan that utilizes Standard service or above. For this demo, I would recommend using the Standard plan because it allows you to cheaply test most of what the service has to offer and will support production workloads. 

Figure 4 – Service Pricing Plan

Further refinements 

The rest of the pages of the Create Web App wizard have further options that can change how your application is accessed and managed.  For the demo choose the default options but feel free to review the documentation for more information on the choices available.  Below are screenshots of some of those pages for Networking and Monitoring. 

Create Web App (Networking Page) 
Create Web App
Figure 5 – Networking Page
Create Web App (Monitoring Page) 
Create Web App (Monitoring Page) 
Figure 6 – Monitoring Page
Create Web App (Review and Create a Page) 

Review the choices that you’ve made on the Review + create page and double check that everything is as you expect it to be. When you are ready, press the Create button, and Microsoft Azure will begin to provision all of the resources for your application. When everything has been successfully created move on to the next steps.

Create Web App (Review and Create a Page)
Figure 7 – Review and Create a Page

PowerShell Deployment 

Everything that was demonstrated in this demo can also be done using PowerShell.  Additionally, below are some of the commands that you can use to script the creation of the required Azure Resources. You must already be logged in to the Azure PowerShell Console to use the commands.

New-AzResourceGroup -Name “demoapp” -Location “eastus” 

New-AzAppServicePlan -Name “demoappplan” -Location “eastus” -ResourceGroupName “demoapp” -Tier Free 

New-AzWebApp -Name “demowebapp” -Location “eastus” -AppServicePlan “demoappplan” -ResourceGroupName “demoapp” 

Set-AzAppServicePlan -Name “demoappplan” -ResourceGroupName “demoapp” -Tier Standard 

Connect an existing ASP.NET Core Web App to the newly Created Azure App Service 

The next steps in this section are not necessary if you already have a web application that you would like to deploy to the Azure App Service to test. However, it is recommended that the first time you deploy any web application to Azure you should choose a simple application that does not require several other resources to run.  This will help you learn and try out new things as you get more familiar with the Azure App Service and other Azure fundamentals.  Choosing a complicated application, even one with simple SQL dependencies that do not already exist can cause issues with first deployments so it is better to deploy a simple application first. 

Steps to create an ASP.NET Core Web Application to deploy to the previously created Azure App Service 

  • Open Visual Studio and click “Create a New Project.” 
  • Select ASP.NET Core Web App (Model-View-Controller) and then click “Next.” 
  • On the “Configure your new project” screen, name your application DemoAzureApp, choose the Location to save it to, and click next. 
  • On the next screen, leave the settings regarding things such as Framework and Authentication type set as their default settings. The Framework should be set to .NET 6.0 (Long Term Support) as of the date of this article being published. 
  • Click “Create” to create the new ASP.NET Core Web Application. 
  • You now have a Web Application that you can deploy to Azure.
  • Feel free to make some changes to some of the views so that they will be visible once you’ve deployed the application to Azure.
  • When you’re ready move on to the next section.
Configure your next project
Figure 8 – Configure your new project
Azure App Service: Additional Information
Figure 9 – Additional Information

Steps to publish your existing Web Application to the Azure App Service 

  • Select the “Build Menu” in Visual Studio and select “Publish DemoAzureApp.” 
  • If you have not added a publish profile to your app then the Publish dialog box will display automatically.  If you already have a publish profile, choose “Add a publish profile” to display the dialog for the next steps. 
  • Select “Azure” as the target that we will be publishing to and press the “Next” button. 
  • Choose “Azure App Service (Windows)” as the “Specific Target” and then press the “Next” button. 
  • On the “Select existing or create a new Azure App Service” add or choose the Azure account that you used to create the Azure App Service earlier to enable the drop-down with the available subscriptions 
  • Choose the subscription that the Azure App Service exists in. 
  • Locate and select the Azure App Service in the tree view below and press the “Finish” button. 
  • You now have your Web Application ready to publish to the Azure App Service 
  • To publish the App, press the “Publish” button on the Publish Profile screen. 
  • Following this, it will build and deploy your application to the Azure App Service. 
  • After it has been successfully built and deployed your application will start and warm up which can take a few minutes. 
  • When this is done your application should open in a new browser window. 
  • Congratulations, you now have a web application hosted in the Azure Cloud!
Publish Application to the Microsoft Cloud
Figure 10 – Publish to the Microsoft Cloud
Hosting your application
Figure 11 – Hosting your Application

Summary 

While it can seem overwhelming to migrate any application to a new platform, taking a few steps to learn and try things out first can help you understand how hard it will be.  We hope from the example above that you will see that getting started is possible and that many things in the cloud are similar to a standard application deployment.  From the resources below you can also learn more about deploying an application with a cloud-hosted SQL database and other more advanced topics.  While this is just a starting point it is an important first step and one that can be returned to, to try out new concepts such as continuous deployment, automated backup, and scaling strategies. 

Next Steps 

Now that you’ve deployed your first application below are some activities that you could investigate as additions to any cloud-hosted application: 

  • Integrate user Authentication and Authorization with Azure Active Directory (Microsoft Entra ID) 
  • Set up and integrate with Azure SQL to host databases. 
  • Add a custom domain and SSL certificate. 
  • Utilize Azure Key Vault for storing secrets, keys, and sensitive information. 
  • Investigate using Azure App Configuration for application configuration. 
  • Implement CI/CD using Azure DevOps or Azure Pipelines. 

Resources for further learning/research 

https://learn.microsoft.com/en-us/azure/app-service/

https://learn.microsoft.com/en-us/azure/app-service/quickstart-dotnetcore

https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/azure-apps/

https://learn.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-dotnet-sqldatabase