Add Windows Server 2019 Image to AzureStack #AzureStackDevKit #WindowsServer2019

| ,

Published on | Updated on December 28, 2020

3 Min. Read

Introduction

Hello folks,

You might have seen the announcement on Windows Server 2019 preview that went out recently.

After installing Azure Stack Development Kit (ASDK) or Azure Stack Integrated Systems, we need to add a default Windows Server or Linux Image. If you deployed Azure Stack in connected mode and register it with public Azure, you can download Azure marketplaces items (known as marketplace syndication). For more details about this process, please check my earlier post below here.

Since Windows Server 2019 is just released in preview, the image is not available yet in public Azure, at the time of writing we cannot download it to Azure Stack.

In this post, I will show you how to add a custom Windows Server 2019 image to Azure Stack with PowerShell.

Add Windows Server 2019 image to Azure Stack

Assuming you already downloaded Azure Stack PowerShell and the required tools as described in the article above.

To create Windows Server 2019 custom image, complete the following steps:

  1. We need to prepare Windows Server 2019 image (fixed disk) in VHD format and NOT in VHDX format. Please note that Azure Stack does not support dynamic disks.
  2. Download Windows Server 2019 preview ISO image from here.
  3. Download Convert-WindowsImage.ps1 script from here.
  4. You can run the following script to create the image.
    # Load (aka dot-source) the Function 
    . .\Convert-WindowsImage.ps1 
    
    # Prepare all the variables
    $ConvertWindowsImageParam = @{  
        SourcePath          = "D:\ASDK\Windows_InsiderPreview_Server_vNext_en-us_17623.iso"
        RemoteDesktopEnable = $True  
        Passthru            = $True
        WorkingDirectory    = "E:\Temp\"
        SizeBytes           = 40GB
        DiskType            = "Fixed"
        VHDFormat           = "VHD"
        VHDPartitionStyle   = "MBR"  
        Edition    = @(       
            "ServerDatacenter" 
        )  
     }  
    
    # Produce the image 
    $VHD = Convert-WindowsImage @ConvertWindowsImageParam

To add Windows Server 2019 image to the Azure Stack Marketplace, complete the following steps:

  1. Import AzureStack Connect and ComputeAdmin modules:
    # Import the Connect and ComputeAdmin Modules
    Set-Location C:\AzureStack-Tools-master\Connect
    Import-Module .\AzureStack.Connect.psm1 -Verbose
    
    Set-Location C:\AzureStack-Tools-master\ComputeAdmin
    Import-Module .\AzureStack.ComputeAdmin.psm1 -Verbose
  2. Login to Azure Stack environment by running the following command:
    # Set the ARM Endpoint For Azure Stack Development Kit
    $ArmEndpoint = "https://adminmanagement.local.azurestack.external"
    
    # Set the Graph For Azure Stack Development Kit
    $GraphAudience = "https://graph.windows.net/"
    
    # Create the Azure Stack operator's Azure Resource Manager environment by using the following cmdlet:
    Add-AzureRMEnvironment -Name "AzureStackAdmin" -ArmEndpoint $ArmEndpoint
    
    # Note: For Azure Active Directory (AAD) run the following command
    Set-AzureRmEnvironment -Name "AzureStackAdmin" -GraphAudience $GraphAudience
    $TenantID = Get-AzsDirectoryTenantId -AADTenantName "https://charbelnemnom.com" -EnvironmentName AzureStackAdmin
    
    # Note: For Active Directory Federation Services (ADFS) run the following command
    Set-AzureRmEnvironment -Name "AzureStackAdmin" -GraphAudience $GraphAudience -EnableAdfsAuthentication:$true
    $TenantID = Get-AzsDirectoryTenantId -ADFS -EnvironmentName AzureStackAdmin
    
    # Login to Azure Stack
    Login-AzureRmAccount -EnvironmentName "AzureStackAdmin" -TenantId $TenantID
  3. Add Windows Server 2019 custom VM image by running the following command:
    # Add Windows Server 2019 Image
     Add-AzsVMImage `
     -Publisher "Microsoft" `
     -Offer "WindowsServer" `
     -Sku "Datacenter2019" `
     -Version "17623.0.0" `
     -OsType Windows `
     -OSDiskLocalPath "E:\Temp\17623_WindowsServer2019_Datacenter_en-US.vhd"

    And that process takes a little bit of time. In this example, it took little over 6 minutes.

    Add Windows Server 2019 Image to AzureStack #AzureStackDevKit #WindowsServer2019 1

    What happens behind the scenes is the following: First, we will authenticate to the Azure Stack environment, upload the local VHD image to a newly created temporary storage account, and then adds the VM image to the VM image repository, and finally creates a Marketplace item. When the image is added successfully, you will receive a similar message to the following:  Add Windows Server 2019 Image to AzureStack #AzureStackDevKit #WindowsServer2019 2

Verify Windows Server 2019 image is available in Azure Stack

To verify that the image is added successfully, in the portal, go to the Marketplace, and verify that the VM image is available in the Compute category.

Add Windows Server 2019 Image to AzureStack #AzureStackDevKit #WindowsServer2019 3

The final step is to deploy the new image and verify that is running successfully. In the portal, go to New, click on Compute, select the newly added image and Create a new virtual machine.

Add Windows Server 2019 Image to AzureStack #AzureStackDevKit #WindowsServer2019 4

Happy Evaluating Windows Server 2019 preview in Azure Stack!

Add Windows Server 2019 Image to AzureStack #AzureStackDevKit #WindowsServer2019 5

__
Thank you for reading my blog.

If you have any questions or feedback, please leave a comment.

-Charbel Nemnom-

Previous

Migrate Windows VM From Unmanaged Disks To Managed Disks with Azure PowerShell

#HitRefresh – New Chapter – Moving Over to The #Microsoft Cloud Side… Starting on a new Job @itnetx_CH #Switzerland #HackYourCareer

Next

Leave a comment below...

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

Subscribe to Charbel Nemnom’s Blog

Get the latest posts delivered right to your inbox

The content of this website is copyrighted from being plagiarized! However, you can copy from the 'Code Blocks'.

Please send your feedback to the author using this form for any 'Code' you like.

Thank you for visiting!