Azure as Development Environment for Azure Stack

If you are planning the deployment of Microsoft Azure Stack in your Networking Environment, the good question is always: How many Azure Stack Enviornments do I need to order to fullfill my companies strategy to have:

  1. Testenvironment
  2. Development Enivronment
  3. Production Environment

Does this mean I need to buy Azure Stack three times?

The answer is NO!

There is a policy for Azure available to set up a resource group or a complete subscription to behave as Azure Stack. This is described here: https://docs.microsoft.com/en-us/azure/azure-stack/user/azure-stack-policy-module.

Or to make it easier, the complete script is the following. 

Note: Please be careful that as of now there is a typo in docs that refers to the wrong PowerShell CMDlet!

 

Set-PSRepository `
 -Name "PSGallery" `
 -InstallationPolicy Trusted

Get-Module -ListAvailable | where-Object {$_.Name -like “Azure*”} | Uninstall-Module

# Install the AzureRM.Bootstrapper module. Select Yes when prompted to install NuGet 
Install-Module `
 -Name AzureRm.BootStrapper

# Install and import the API Version Profile required by Azure Stack into the current PowerShell session.
Use-AzureRmProfile `
 -Profile 2017-03-09-profile -Force

Install-Module `
 -Name AzureStack `
 -RequiredVersion 1.2.11

# Change directory to the root directory 
cd \

# Download the tools archive
invoke-webrequest `
 https://github.com/Azure/AzureStack-Tools/archive/master.zip `
 -OutFile master.zip

# Expand the downloaded files
expand-archive master.zip `
 -DestinationPath . `
 -Force

# Change to the tools directory
cd AzureStack-Tools-master

# Navigate to the downloaded folder and import the **Connect** PowerShell module
Set-ExecutionPolicy RemoteSigned
Import-Module .\Connect\AzureStack.Connect.psm1

# For Azure Stack development kit, this value is set to https://management.local.azurestack.external. To get this value for Azure Stack integrated systems, contact your service provider.
$ArmEndpoint = "<Resource Manager endpoint for your environment>"

# For Azure Stack development kit, this value is set to https://graph.windows.net/. To get this value for Azure Stack integrated systems, contact your service provider.
$GraphAudience = "<GraphAudience endpoint for your environment>"

# Register an AzureRM environment that targets your Azure Stack instance
Add-AzureRMEnvironment `
 -Name "AzureStackUser" `
 -ArmEndpoint $ArmEndpoint

# Set the GraphEndpointResourceId value
Set-AzureRmEnvironment `
 -Name "AzureStackUser" `
 -GraphAudience $GraphAudience

# Get the Active Directory tenantId that is used to deploy Azure Stack
$TenantID = Get-AzsDirectoryTenantId `
 -AADTenantName "<myDirectoryTenantName>.onmicrosoft.com" `
 -EnvironmentName "AzureStackUser"

# Sign in to your environment
Login-AzureRmAccount `
 -EnvironmentName "AzureStackUser" `
 -TenantId $TenantID

Login-AzureRmAccount
Import-Module .\Policy\AzureStack.Policy.psm1

$resourceGroupName = ‘<MyRG>’
$s = Select-AzureRmSubscription -SubscriptionName "<MySubscription>"
$subId = $s.Subscription.SubscriptionId

$policy = New-AzureRmPolicyDefinition -Name AzureStackPolicyDefinition -Policy (Get-AzsPolicy)
New-AzureRmPolicyAssignment -Name AzureStack -PolicyDefinition $policy -Scope /subscriptions/$subId/resourceGroups/$resourceGroupName

 

Post author

Leave a Reply