After installing Azure Stack Development Kit (ASDK) or Azure Stack Integrated Systems, we need to add a default Windows Server 2016 or Linux Image. But before doing so, we have to complete a couple of tasks.
In this blog post, I will show you how to set up PowerShell for Azure Stack, then register Azure Stack with Azure subscription, and finally add a Windows Server 2016 image.
Set up PowerShell for Azure Stack
Login to Azure Stack Development Kit. Open an elevated PowerShell ISE session, and then run the following script:
# Set Execution & Repository policies
$ResetExPol = Get-ExecutionPolicy
Set-ExecutionPolicy Unrestricted -force
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted
### Install and Import AzureStack Modules 1.2.11 & Tools
Install-Module -Name AzureRm.BootStrapper
Use-AzureRmProfile -Profile 2017-03-09-profile -Force
Install-Module -Name AzureStack -RequiredVersion 1.2.11
Import-Module -Name AzureStack -RequiredVersion 1.2.11
invoke-webrequest https://github.com/Azure/AzureStack-Tools/archive/master.zip -OutFile master.zip
expand-archive master.zip -DestinationPath . -Force
### Reset Execution Policy back to default
Set-ExecutionPolicy $ResetExPol -Force
### Specify Azure Active Directory tenant name.
$TenantName = "directoryname.onmicrosoft.com" # Specify Azure Active Directory Name
### For Azure Stack development kit, this value is set to https://adminmanagement.local.azurestack.external.
$ArmEndpoint = "https://adminmanagement.local.azurestack.external"
### For Azure Stack development kit, this value is adminvault.local.azurestack.external
$KeyvaultDnsSuffix = “adminvault.local.azurestack.external”
### Register an AzureRM environment that targets your Azure Stack instance
Add-AzureRMEnvironment -Name "AzureStackAdmin" -ArmEndpoint $ArmEndpoint
### Get the Active Directory tenantId that is used to deploy Azure Stack
$TenantID = Get-AzsDirectoryTenantId -AADTenantName $TenantName -EnvironmentName "AzureStackAdmin"
### Sign in to Azure Stack environment
Login-AzureRmAccount -EnvironmentName "AzureStackAdmin" -TenantId $TenantID
Here’s a quick overview of what the script above is doing:
- Set PowerShell Execution and PowerShell repository
- Install and import AzureStack Modules version 1.2.11
- Download and install AzureStack-Tools
- Import Azure Stack connect and compute modules
- Reset PowerShell Execution Policy back to default
- Register Azure Resource Manager (AzureRM) environment with Azure Stack Instance
- Login to Azure Stack environment
Now that you have set up PowerShell for Azure Stack, I will keep PowerShell ISE console open for the time being, we’ll be using it in the subsequent sections.
If you want to confirm that everything is working as expected, you can test the configuration by creating a test resource group by running the command below:
### Test Azure Stack Connectivity by creating a Resource Group
New-AzureRMResourceGroup -Name "Test-ASDK-RG01" -Location Local
After the resource group is created, the Provisioning state property is set to Succeeded as shown in the next screenshot.
Register Azure Stack with Azure Subscription
This is step is not required, but it’s recommended because it enables you to test and download Azure marketplaces items from public Azure (known as Marketplace Syndication).
Before you start registering Azure Stack with Azure, you must have a subscription ID for an active Azure subscription.
Log into your Azure Subscription at https://portal.azure.com and grab your subscription ID that you want to register with Azure Stack. You might have multiple subscriptions.
Once you have the subscription ID, login to the Azure Stack host computer and run the following PowerShell script to register Azure Stack with Azure.
### Register Azure Stack Resource Provider with Azure
# This step only needs to be completed once in an Azure Stack environment
Login-AzureRmAccount -EnvironmentName "AzureCloud"
Register-AzureRmResourceProvider -ProviderNamespace Microsoft.AzureStack
### Register Azure Stack Environment with Azure
# Specify Azure Active Directory Name
$AADTenantName = "directoryname.onmicrosoft.com"
$ASDKAdminCred = Get-Credential ("AzureStack\AzureStackAdmin")
# Specify Azure Subscription ID that you want to use
$AzureSubscriptionID = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
# This should be the IP address for the Azs-ECRS01 VM that's deployed as part of ASDK
$PrivilegedEndpoint = "192.168.200.225"
### Import the Register With Azure Module
Import-Module .\RegisterWithAzure.psm1 -Verbose
### Run the Azure registration cmdlet
-CloudAdminCredential $ASDKAdminCred `
-AzureDirectoryTenantName $AADTenantName `
-AzureSubscriptionId $AzureSubscriptionID `
-PrivilegedEndpoint $PrivilegedEndpoint `
Here’s a quick overview of what the script above is doing:
- Logs into your Azure account. You’ll be prompted for credentials, enter the credentials of a Global Administrator for your subscription
- Registers the “Microsoft.AzureStack” resource provider with your Azure account
- Specify the AAD Tenant Name, Azure Stack admin credentials, Azure Subscription ID and the IP address for the Privileged Endpoint VM that was deployed as part of Azure Stack
- Import the Register With Azure Module
- Finally, activating Azure Stack with Azure (this may take up to 10 minutes to complete)
Add Windows Server 2016 Image to Azure Stack
In the final section, we will download and add Windows Server image from Azure to Azure Stack. This step requires that you have registered your Azure Stack instanced with Azure. If you have deployed Azure Stack in a disconnected scenario, or in scenarios with limited connectivity, the check the following article on how to add the image in offline mode by using PowerShell.
- Log into your Azure Stack Development Kit portal at: https://adminportal.local.azurestack.external/
- Select More services > Marketplace Management > Click on +Add from Azure. (You should now be presented with a populated Marketplace items)
- Search for the Windows Server 2016 Datacenter – Eval image
- Select the image and click Download. The image download size is 40GB, so it will take some time to complete.
- When the download is finished successfully, you can see the image is available under Marketplace management. The image also is available under Virtual machines.
That’s it there you have it. You can now start provisioning virtual machines… Until then, see you in the next post!
Thanks for reading!