October 13, 2024

SamTech 365

PowerPlatform, Power Apps, Power Automate, PVA, SharePoint, C#, .Net, SQL, Azure News, Tips ….etc

Create Azure Web Apps using PowerShell

Azure Web Apps

In this article, I will show you how to quickly create an Azure Web App using Powershell as an alternative of using the portal or Azure CLI.

The creation of an azure web app has three steps.

Step 1: Create a resource group

As your application will be running within a resource group, it is logical to create Azure Web Apps a new one (if you don’t want to hook the app to an existing resource group).

Step 2: Create an app service plan

Depending on whether you will be deploying a small or large application, for dev or production purposes, you have to select the appropriate service plan.

If you want to know the different options you have, please visit https://azure.microsoft.com/en-gb/pricing/details/app-service/windows/

You can either pick the free & shared service plan, standard Azure Web Apps or premium, the previous link explains in detail the differences in performances and cost between these plans.

Step 3: Create your app

At this stage, we have everything we need, we just create the app and attach it to the resource group and assign it a service plan.

# Create variables
$webappname = "mywebapp$(Get-Random)"
$rgname = 'webapps3-dev-rg'
$location = 'westus2'

# Create a resource group
New-AzResourceGroup -Name $rgname -Location $location

# Create an App Service plan in S1 tier
New-AzAppServicePlan -Name $webappname -Location $location -ResourceGroupName $rgname -Tier S1

# Create a web app
New-AzWebApp -Name $webappname -Location $location -AppServicePlan $webappname -ResourceGroupName $rgname