slide

Some helper scripts for Azure Stack Development Kit

Ned Bellavance
2 min read

Cover

Not too long ago, I got a DL380 Gen10 from HPE to deploy the Azure Stack Development Kit. I had been limping along with a couple Frankstein systems running on Gen8 and Gen9 hardware. They had slow disks, not enough storage, and not enough RAM. This new beast has 384GB of RAM, 20 cores, and SSDs for the OS disk. Basically it’s awesome, and I am a very happy nerd. Since the early days of the ASDK, when it was just a little Technical Preview, there have appeared a growing library of scripts to help with the deployment of the ASDK. Since I am deploying the latest version today (1811), I thought it might be a good idea to share some helper scripts I put together to make the process a bit faster.

Below are two scripts that will help grease the deployment wheels. The first is meant to simplify the download of the ASDK files. If you are deploying for the first time, you should fill out the form on the Microsoft website and agree to whatever the EULA is for the ASDK. That being said, if this is the 20th time you’re deploying the ASDK, filling out the form and getting the downloader executable is a bit of a hassle. This script replaces that downloader executable and just pulls down the bin files and extraction executable to the location of your choice. It also grabs the askd-installer.ps1 file for good measure. After all, once you have the VHDX to deploy the ASDK, the next natural step is to actually deploy the dang thing.

The second script helps out with the process of pulling and running the ConfigASDK.ps1 script written by the excellent Matt McSpirit. I based it off this post by Kristopher Turner. I added a little piece to download the Server 2016 ISO. That’s an eval copy, so don’t be surprised if it expires after 120 days. Of course, after 120 days you’re probably going to redeploy the ASDK to get the latest version anyhow.

<#
This script is meant to make downloading the latest ASDK a simple affair. The files that
make up the ASDK are an executable and several bin files. This script will grab the
latest version of the ASDK from the web and then assemble the bin files into the final VHDX.
Make sure you have 40GB of free space on your C drive, or change the destination!
This does not include the process of installing the ASDK. That's a whole separate thing.
#>
#Set up the path and source URI
$asdkDownloadPath = "C:\ASDKFiles"
$asdkExtractFolder = "ExtractedFiles"
$asdkURIDownloads = "https://aka.ms/azurestack-asdkdownloads"
#Get the release info
$resp = Invoke-RestMethod -Method Get https://aka.ms/azurestack-asdkdownloads
$resp2 = Invoke-RestMethod -Method Get -Uri $resp.DownloadProduct.DownloadReleases.Uri
#Get the list of files and create a destination path for each
$downloadList = $resp2.DownloadFileList.Files.FileName
$AsdkFiles = @()
foreach ($AsdkFile in $downloadList)
{
$AsdkFiles += Join-Path -Path $asdkDownloadPath -ChildPath $AsdkFile
}
#Use BITS to download the files, these are BIG
$downloadList | ForEach-Object {Start-BitsTransfer -Source "$($resp2.DownloadFileList.DownloadSource)$_" -DisplayName $_ -Destination $asdkDownloadPath -Asynchronous}
#This while loop will run until all the BITS transfers are complete, that might be a while
#Maybe go get lunch or call your mother. She likes that sort of thing.
while(Get-BitsTransfer){Get-BitsTransfer | ?{$_.JobState -eq "Transferred"} | Complete-BitsTransfer}
#Now we extract the VHDX from all those bin files
$f = $AsdkFiles | Where-Object {$_ -like "*.exe"}
$o = Join-Path -Path $asdkDownloadPath -ChildPath $asdkExtractFolder
Start-Process -FilePath $f -ArgumentList "/dir=`"$o`"", "/SILENT", "/NOCANCEL" -Wait
#Now that you have the full VHDX, go get the asdk-installer script
$Uri = 'https://raw.githubusercontent.com/Azure/AzureStack-Tools/master/Deployment/asdk-installer.ps1'
$LocalPath = 'C:\AzureStack_Installer'
# Create folder
New-Item $LocalPath -Type directory
# Enforce usage of TLSv1.2 to download from GitHub
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
# Download file
Invoke-WebRequest $uri -OutFile ($LocalPath + '\' + 'asdk-installer.ps1')
<#
This script is meant to download and run the ConfigASDK script created by Matt McSpirit.
You can check that out here: https://github.com/mattmcspirit/azurestack/tree/master/deployment
This will install EVERYTHING. That includes the MySQL, SQL, and AppService RPs. You will need
to download the Server 2016 ISO ahead of time as well. That
#>
#Create the destination for files
New-Item -ItemType Directory -Force -Path “D:\ConfigASDK”
New-Item -ItemType Directory -Force -Path “D:\ASDKFiles”
Set-Location “D:\ConfigASDK”
#Get Server 2016 ISO
Start-BitsTransfer -Source https://software-download.microsoft.com/download/pr/Windows_Server_2016_Datacenter_EVAL_en-us_14393_refresh.ISO -Destination D:\ConfigASDK\Windows_Server_2016_Datacenter.ISO
#Get the latest version of the script
Invoke-Webrequest http://bit.ly/configasdk -UseBasicParsing -OutFile ConfigASDK.ps1
#Update the variables with the correct value
$azureDirectoryTenantName = "XXX.onmicrosoft.com"
$azureAdUsername = "admin@XXX.onmicrosoft.com"
$azureAdPassword = 'password for the Azure AD User'
$azueRedSubId = "YOUR-SUB-ID-HERE"
$ISOPath = "D:\ConfigASDK\Windows_Server_2016_Datacenter.ISO"
$password = 'Password to use for all the VMs'
#Run the ConfigASDK and go out for lunch, dinner, and probably dessert. You've earned it!
.\ConfigASDK.ps1 -azureDirectoryTenantName $azureDirectoryTenantName -authenticationType AzureAD `
-downloadPath "D:\ASDKfiles" -ISOPath $ISOPath -azureStackAdminPwd $password -VMpwd $password `
-azureAdUsername $azureAdUsername -azureAdPwd $azureAdPassword -registerASDK -useAzureCredsForRegistration `
-azureRegSubId $azueRedSubId

I hope this helps out someone besides me. I would also recommend checking out Kenny Lowe’s post about exposing your ASDK to your network.