Tuesday, March 26, 2019

Creating Azure Web App using PowerShell and Visual Studio


In last sections, We have learned how to create the App Service, Hosting plans and created the web app through Azure Portal.

In this section, we are going to learning the various methods on creating the web app.

  1. Azure PowerShell
  2. Azure SDK.NET (Visual Studio )
  3. Azure CLI (Command line interface) and
  4. Azure Resource Management Template(ARM)

In all above methods these are the mandatory parameters
  1. ResourceGroupName
  2. Location
  3. Name and
  4. AppServicePlan

I ) Creating the Azure Web App - Azure PowerShell

Azure PowerShell Command for creating the new web app

Before using the below command ensure, that Azure Module has been installed on your machine.

You must have PowerShell Version 5.1 or higher to install the Azure Module and connect to Azure Services. Confirm the PowerShell version, by typing the below command in PowerShell Window

$PSVersionTable.PSVersion

If it is greater that 5.1

and now install the Azure Module, use the below command, please ensure that you are running the PowerShell command window as Administrator.

Install-Module -Name Az -AllowClobber

You need to trust this repository, to install all the modules, so select Y or A
Now you will see the Installation progress as shown in the attached images
Now run this command to create the Web App, First you need to login to your Azure account



Installing the Azure Module in Power Shell



PS C:\> Connect-AzAccount


This will open the browser window and prompt you to log into your Azure account.
Once its connected, You can see your subscription details in the command window.

PS C:\>New-AzWebApp -ResourceGroupName Default-Web-WestUS -Name "yourwebsite" -Location "West US" -AppServicePlan "AppServicePlanName"


II ) Creating the Azure Web App Service and Web App

Creating through the Visual Studio, ensure you have installed the Azure SDK.NET on your machine before connection to Azure and Publish your website to it.


For my personal experience, I have just selected the ASP.NET core application 2.0 and it push nearly 45.8 MB files including all Azure related assemblies in to it.

And it takes at least 3 minutes to publish the simple default template website.

Its better not to use the Visual Studio to create the WebApp.