powershellazurecloudazure-stack

How to create azure stack in azure cloud


We are creating Azure stack in azure cloud by following docs of Microsoft Azure.

We are stuck at this documentaion : https://learn.microsoft.com/en-us/azure/azure-stack/azure-stack-policy-module

at this heading : Apply policy to a resource group

$resourceGroupName = ‘myRG01’
$s = Select-AzureRmSubscription -SubscriptionName "<Azure Subscription Name>"
$policy = New-AzureRmPolicyDefinition -Name AzureStackPolicyDefinition -Policy (**Get-AzureStackRmPolicy**)
New-AzureRmPolicyAssignment -Name AzureStack -PolicyDefinition $policy -Scope /subscriptions/$subscriptionID/resourceGroups/$rgName

when we are running the above PowerShell script, we observe the below mentioned error:

Get-AzureStackRmPolicy : The term 'Get-AzureStackRmPolicy' is not recognized as the name of a cmdlet, function, script file, or operable 
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:2 char:81
+ ... ion -Name AzureStackPolicyDefinition -Policy (Get-AzureStackRmPolicy)
+                                                   ~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-AzureStackRmPolicy:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Solution

  • When we replaced Get-AzureStackRmPolicy with Get-AzsPolicy we were able to create all the resources, We got this after looking in to the script provided by Microsoft in their github repo.