In this article, we will show you how to add a Linux image to Azure Stack Development Kit (ASDK) in a disconnected scenario using PowerShell.
Table of Contents
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.
Download a Linux operating system image
First, we need to download a Linux Ubuntu 16.04 LTS operating system image.
1) Open the 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 'admin@addirectory.onmicrosoft.com' -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 = 'admin@addirectory.onmicrosoft.com'
$adminPassword = 'P@ssw0rd!' | ConvertTo-SecureString –Force –AsPlainText
$adminCredentials = New-Object PSCredential($adminUserName,$adminPassword)
Login-AzureRmAccount –EnvironmentName ‘AzureStackAdmin’ -TenantId $AADTenantID -Credential $adminCredentials
Leave the 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 the 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 the 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,
-Ch@rbel