Creating a Web App and Deploying Code from GitHub Using PowerShell

1.75 hours
  • 4 Learning Objectives

About this Hands-on Lab

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
  1. Open a new terminal.

  2. Copy the public IP address provided with this hands-on lab.

  3. In the terminal, connect to the VM:

    ssh cloud_user@<PUBLIC_IP_OF_THE_VM>
  4. Once logged in, start the PowerShell prompt:

    pwsh 
Install the Az Module and Connect to Azure
  1. Install the module:

    Install-Module -Name Az -AllowClobber -Scope CurrentUser
  2. Enter Y to continue installing from the PowerShell gallery.

  3. From the PowerShell prompt, connect to Azure:

    Connect-AzAccount -UseDeviceAuthentication
  4. Go to https://microsoft.com/devicelogin and enter the code provided in the terminal.

  5. Enter the Azure Portal username and password provided with this hands-on lab.

Create the Azure App Service Plan and Web App
  1. 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>'
  2. Create the app service plan:

    New-AzAppServicePlan -Name $webappname -Location $location -ResourceGroupName $resourceGroup -Tier Free
  3. Create the web app:

    New-AzWebApp -Name $webappname -Location $location -AppServicePlan $webappname -ResourceGroupName $resourceGroup
Create and Apply the Configuration to the Web App
  1. Create the variable for the GitHub configuration:

    $PropertiesObject = @{
      repoUrl = "$gitrepo";
      branch = "master";
      isManualIntegration = "true";
    }
  2. 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

Additional Resources

We have provisioned a Linux VM for you to use with this hands-on lab. You must use the PowerShell prompt to complete any and all tasks. The objective is to deploy an Azure web app and modify the code in the application with the configuration stored in a GitHub repository.

In order to complete this hands-on lab, perform the following:

  • Log in to the VM with the given credentials.
  • Open PowerShell and install the Az module.
  • Connect to the Azure account using the provided credentials.
  • Perform the necessary commands to create an app service plan and a web app.
  • Perform the necessary commands to apply the configuration from this GitHub repo: https://github.com/chadmcrowell/app-service-web-dotnet-get-started.git.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Get Started
Who’s going to be learning?

How many seats do you need?

  • $499 USD per seat per year
  • Billed Annually
  • Renews in 12 months

Ready to accelerate learning?

For over 25 licenses, a member of our sales team will walk you through a custom tailored solution for your business.


$2,495.00

Checkout
Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!