New-AzWebApp

How to create an Azure web app using PowerShell

This Azure tutorial will discuss how to create an Azure web app using the PowerShell command New-AzWebApp and its syntax with examples.

New-AzWebApp

New-AzWebApp is an excellent Azure PowerShell cmdlet that can help you quickly create an Azure Web App for a specified resource group, App Service Plan.

You need to specify key parameters along with this Azure PowerShell cmdlet, like name, resource group name, location, App Service Plan, etc.

Syntax of New-AzWebApp

The syntax of the New-AzWebApp Azure PowerShell cmdlet is as follows.

New-AzWebApp
[[-ResourceGroupName] <String>]
 [-Name] <String>
 [[-Location] <String>]
   [[-AppServicePlan] <String>]
 [-ContainerImageName <String>]
[-EnableContainerContinuousDeployment]
 [-AsJob]
[-GitRepositoryPath <String>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]

New-AzWebApp Example

Let’s consider the below example. Here we will create an Azure Web App named “TSINFOSite” with the resource group name “Demo123”, Location is “East US”, and the App Service Plan as “TSINFOASP12”.

Execute the below Azure PowerShell Cmdlet.

PS C:\WINDOWS\system32> New-AzWebApp -ResourceGroupName Demo123 -Name "TSINFOSite" -Location "East US" -AppServicePlan "TSINFOASP12
"

Once you execute the above Azure PowerShell cmdlet, you will get the output like the one below

GitRemoteName               : 
GitRemoteUri                : 
GitRemoteUsername           : 
GitRemotePassword           : 
AzureStorageAccounts        : 
AzureStoragePath            : 
State                       : Running
HostNames                   : {tsinfosite.azurewebsites.net}
RepositorySiteName          : TSINFOSite
UsageState                  : Normal
Enabled                     : True
EnabledHostNames            : {tsinfosite.azurewebsites.net, 
                              tsinfosite.scm.azurewebsites.net}
AvailabilityState           : Normal
HostNameSslStates           : {tsinfosite.azurewebsites.net, 
                              tsinfosite.scm.azurewebsites.net}
ServerFarmId                : /subscriptions/1cdf4300-dee5-4518-9c9c-feaa72a5cbd1/reso
                              urceGroups/Demo123/providers/Microsoft.Web/serverfarms/T
                              SINFOASP12
Reserved                    : False
IsXenon                     : False
HyperV                      : 
LastModifiedTimeUtc         : 6/25/2021 3:07:32 AM
SiteConfig                  : Microsoft.Azure.Management.WebSites.Models.SiteConfig
TrafficManagerHostNames     : 
ScmSiteAlsoStopped          : False
TargetSwapSlot              : 
HostingEnvironmentProfile   : 
ClientAffinityEnabled       : True
ClientCertEnabled           : False
ClientCertMode              : 
ClientCertExclusionPaths    : 
HostNamesDisabled           : False
CustomDomainVerificationId  : 
OutboundIpAddresses         : 52.170.7.25,52.168.75.147,52.179.5.98,52.179.1.81,52.179
                              .4.232
PossibleOutboundIpAddresses : 52.170.7.25,52.168.75.147,52.179.5.98,52.179.1.81,52.179
                              .4.232,52.179.2.103,52.170.87.19
ContainerSize               : 0
DailyMemoryTimeQuota        : 0
SuspendedTill               : 
MaxNumberOfWorkers          : 
CloningInfo                 : 
ResourceGroup               : Demo123
IsDefaultContainer          : 
DefaultHostName             : tsinfosite.azurewebsites.net
SlotSwapStatus              : 
HttpsOnly                   : False
RedundancyMode              : 
InProgressOperationId       : 
Identity                    : 
Id                          : /subscriptions/1cdf4300-dee5-4518-9c9c-feaa72a5cbd1/reso
                              urceGroups/Demo123/providers/Microsoft.Web/sites/TSINFOS
                              ite
Name                        : TSINFOSite
Kind                        : app
Location                    : East US
Type                        : Microsoft.Web/sites
Tags                        : 

You can see the same output in the below screenshot.

New-AzWebApp

Publish-AzWebApp

Publish-AzWebApp is an Azure PowerShell cmdlet that helps you upload content to an existing Azure Web App. The only thing is the content should be packaged in a ZIP file.

It helps you to deploy the Azure Web App from a ZIP or WAR file with the help of Zip deploy.

Syntax

The Syntax of the Publish-AzWebApp Azure PowerShell cmdlet is as below

Publish-AzWebApp
 -ArchivePath <String>
 [-AsJob]
 [-ResourceGroupName] <String>
       [-Name] <String>
 [[-Slot] <String>]
[-Force]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]

Example:

PS C:\WINDOWS\system32> Publish-AzWebApp -ResourceGroupName Demo123 -Name TSINFOWebApp -ArchivePath C:\MyWork\tsinfoapp.zip

Once you execute the above Azure PowerShell cmdlet, it deploys the content inside the tsinfoapp.zip file to the web app named TSINFOWebApp, which belongs to the resource group Demo123.

Create Azure web app – Video Tutorial

You may like following the below Azure tutorials:

Conclusion

This Azure tutorial will discuss how to create an Azure web app using the PowerShell command New-AzWebApp.

I hope you have enjoyed this article !!!