In this hands-on lab, you will create an Azure web app and insert configuration information into that web app using the code from a GitHub repository — all using PowerShell. PowerShell is a powerful scripting and automation engine that can be used to provision and automate a lot of tasks in Azure.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Log in to the Linux VM
Open a new terminal.
Copy the public IP address provided with this hands-on lab.
In the terminal, connect to the VM:
ssh cloud_user@<PUBLIC_IP_OF_THE_VM>
Once logged in, start the PowerShell prompt:
pwsh
- Install the Az Module and Connect to Azure
Install the module:
Install-Module -Name Az -AllowClobber -Scope CurrentUser
Enter
Y
to continue installing from the PowerShell gallery.From the PowerShell prompt, connect to Azure:
Connect-AzAccount -UseDeviceAuthentication
Go to
https://microsoft.com/devicelogin
and enter the code provided in the terminal.Enter the Azure Portal username and password provided with this hands-on lab.
- Create the Azure App Service Plan and Web App
Create the following variables (replacing
<UNIQUE_WEB_APP_NAME>
with a globally unique name):$gitrepo = "https://github.com/chadmcrowell/app-service-web-dotnet-get-started.git" $webappname = "<UNIQUE_WEB_APP_NAME>" $location = "West US" $resourceGroup = '<RESOURCE_GROUP_PROVISIONED_WITH_LAB>'
Create the app service plan:
New-AzAppServicePlan -Name $webappname -Location $location -ResourceGroupName $resourceGroup -Tier Free
Create the web app:
New-AzWebApp -Name $webappname -Location $location -AppServicePlan $webappname -ResourceGroupName $resourceGroup
- Create and Apply the Configuration to the Web App
Create the variable for the GitHub configuration:
$PropertiesObject = @{ repoUrl = "$gitrepo"; branch = "master"; isManualIntegration = "true"; }
Apply the configuration to the web app:
Set-AzResource -PropertyObject $PropertiesObject ` -ResourceGroupName $resourceGroup ` -ResourceType Microsoft.Web/sites/sourcecontrols ` -ResourceName $webappname/web ` -ApiVersion 2015-08-01 ` -Force