How to Add a Linux Image to Azure Stack in Disconnected Mode #AzureStack #AzureStackDevKit #Linux #Azure

3 min read

Introduction

You have a deployment of Microsoft Azure Stack (MAS). You want to add a Linux image to the Azure Stack Marketplace to make it available for deployment. In this scenario, your Azure Stack instance is not registered with an Azure subscription. In other words, Azure Stack is deployed in disconnected mode.

In the previous article, I showed you How to Add Windows Server 2016 Image to Azure Stack from the Azure marketplace.

In this article, I will show you how to add a Linux image to Azure Stack Development Kit (ASDK) in disconnected scenario using PowerShell.

Download a Linux operating system image

First, we need to download a Linux Ubuntu 16.04 LTS operating system image.

  1. Open Windows PowerShell console and run the following command to download the compressed vhd file. The downloaded image is 462 MB.
    $Path = Test-Path -Path C:\Downloads
    If ($Path -eq $false) {
    New-Item -Path C:\Downloads -ItemType Directory
    }
    
    Invoke-WebRequest 'http://cloud-images.ubuntu.com/releases/xenial/release/ubuntu-16.04-server-cloudimg-amd64-disk1.vhd.zip' `
    -OutFile C:\Downloads\ubuntu-16.04-server-cloudimg-amd64-disk1.vhd.zip
  2. Once the download completes, you need to extract the vhd file to C:\Downloads. Run the following command to extract the image. Extraction can take up to 15 minutes to complete. The extracted image size is 30 GB.
    Set-Location –Path ‘C:\Downloads’
    
    Expand-Archive –Path .\ubuntu-16.04-server-cloudimg-amd64-disk1.vhd.zip –DestinationPath . -Force

Connect to Azure Stack

In this step, you will connect to Azure Stack by using PowerShell.

  1. Start Windows PowerShell ISE as Administrator, and run the following commands to install Azure Stack modules:
    # Install Azure Stack modules
    Install-Module -Name AzureRm.BootStrapper
    Use-AzureRmProfile -Profile 2017-03-09-profile -Force 
    Install-Module –Name AzureStack –RequiredVersion 1.2.11
  2. Once the installation of the AzureStack module completes, download and extract the Azure Stack tools by running the following commands:
    # Download and extract the Azure Stack tools
    Set-Location –Path ‘C:\’
    Invoke-WebRequest –Uri https://github.com/Azure/AzureStack-Tools/archive/master.zip -OutFile master.zip
    Expand-Archive –Path .\master.zip –DestinationPath . -Force
    Set-Location –Path C:\AzureStack-Tools-master
  3. Once you extract Azure Stack tools, you need to import the Azure Stack Connect and ComputeAdmin modules by running the following two commands:
    # Import the Azure Stack Connect and ComputeAdmin modules
    Import-Module .\Connect\AzureStack.Connect.psm1 -Verbose
    Import-Module .\ComputeAdmin\AzureStack.ComputeAdmin.psm1 -Verbose
    
  4. Once you import Azure Stack modules, you need to create the Azure Stack cloud operator environment by running the following two commands:
    # Create the Azure Stack cloud operator environment
    Add-AzureRMEnvironment -Name ‘AzureStackAdmin‘ -ArmEndpoint ‘https://adminmanagement.local.azurestack.external'
    Set-AzureRmEnvironment -Name 'AzureStackAdmin' -GraphAudience 'https://graph.local.azurestack.external/'
  5. You need to retrieve the GUID value of the Azure Stack cloud operator by running the following command:
    # Retrieve the GUID value of the Azure Stack cloud operator
    $AADTenantID = Get-AzsDirectoryTenantId -AADTenantName '[email protected]' -EnvironmentName ‘AzureStackAdmin’
  6. In the final step, you need to sign in to Azure Stack by running the following commands:
    # Sign in to Azure Stack
    $adminUserName = ‘[email protected]’
    $adminPassword = ‘[email protected]!’ | ConvertTo-SecureString –Force –AsPlainText
    $adminCredentials = New-Object PSCredential($adminUserName,$adminPassword)
    	 
    Login-AzureRmAccount –EnvironmentName ‘AzureStackAdmin’ -TenantId $AADTenantID -Credential $adminCredentials

Leave Windows PowerShell ISE window open.

Add the Linux operating system image

In this step, you will add the Linux operating system image by using PowerShell.

  1. Run the following commands to add the image:
    # Add the Linux image
    $vhdPath = 'C:\Downloads\xenial-server-cloudimg-amd64-disk1.vhd'
    	 
    Add-AzsVMImage `
      -publisher ‘Canonical’ `
      -offer ‘UbuntuServer’ `
      -sku ‘16.04-LTS’ `
      -version ‘1.0.0’ `
      -osType Linux `
      -osDiskLocalPath $vhdPath
  2. Leave the session running. Adding the Linux image may take from 30 to 60 minutes to complete.

Verify availability of the Linux image

In the final step, you will verify the availability of the Linux image in the Azure Stack portal.

  1. Sign-in to Azure Stack Administration portal as an Azure Stack Cloud Operator at https://adminportal.local.azurestack.external.
  2. In the Azure Stack administrator portal, in the hub menu, click + New.
  3. In the New blade, click Compute.
  4. In the Compute blade, ensure that Canonical-UbuntuServer-16.04-LTS appears in the list of entries.

And there you have it.

Until next time!

Cheers,
[email protected]

About Charbel Nemnom 544 Articles
Charbel Nemnom is a Cloud Architect, ICT Security Expert, Microsoft Most Valuable Professional (MVP), and Microsoft Certified Trainer (MCT), totally fan of the latest's IT platform solutions, accomplished hands-on technical professional with over 17 years of broad IT Infrastructure experience serving on and guiding technical teams to optimize the performance of mission-critical enterprise systems. Excellent communicator is adept at identifying business needs and bridging the gap between functional groups and technology to foster targeted and innovative IT project development. Well respected by peers through demonstrating passion for technology and performance improvement. Extensive practical knowledge of complex systems builds, network design, business continuity, and cloud security.

Be the first to comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.