AzureStack-Tools/Policy
..
AzureStack.Policy.psm1
AzureStack.Provider.Metadata.json
AzureStack.storageSkus.json
AzureStack.vmSkus.json
README.md

README.md

Azure Resource Manager policy for Azure Stack

Instructions below are relative to the .\Policy folder of the AzureStack-Tools repo.

This tool constrains Azure subscription to the capabilities available in the Azure Stack via the Azure Resource Manager policy.

Import-Module .\AzureStack.Policy.psm1

Login-AzureRmAccount
$s = Select-AzureRmSubscription -SubscriptionName "<sub name>"
$subId = $s.Subscription.SubscriptionId

$policy = New-AzureRmPolicyDefinition -Name AzureStack -Policy (Get-AzsPolicy)

New-AzureRmPolicyAssignment -Name AzureStack -PolicyDefinition $policy -Scope /subscriptions/$subId

To constrain only a particular resource group in your Azure subscription to match the capabilities of Azure Stack, specify the resource group in the scope as below when assigning the policy.

#Specify the resource group where you would like to apply the policy
$rgName = 'AzureStack'
New-AzureRmPolicyAssignment -Name AzureStack -PolicyDefinition $policy -Scope /subscriptions/$subID/resourceGroups/$rgName

To remove the Azure Stack policy, run this command with the same scope used when the policy was applied:


Remove-AzureRmPolicyAssignment -Name AzureStack -Scope /subscriptions/$subId/resourceGroups/$rgName
Remove-AzureRmPolicyAssignment -Name AzureStack -Scope /subscriptions/$subId