简体   繁体   中英

Set Azure Location Policy Restriction

I want to define a Azure policy where by deployments can only be made to 'West US' and East US at subscription level.

I understand that I'm trying to populate a array of locations but I'm going wrong some where;

 { "policyRule": { "if": { "not": { "field": "location", "in": "[parameters('allowedLocations')]" } }, "then": { "effect": "deny" } }, "parameters": { "allowedLocations": { "type": "Array", "metadata": { "description": "The list of allowed locations for resources.", "displayName": "Allowed locations", "strongType": "location", "value": [ "West US", "East US" ], } } } } 

Azure policy have a concept of Definitions and Assignments. The JSON you provide fits the format of a definition .

For the policy to take effect, you'll need to assign your definition to the subscription you want policy to apply.

在此处输入图片说明

The policy you are trying to apply is also available as a built-in definition. You can directly assign this definition using Azure portal.

https://portal.azure.com/#blade/Microsoft_Azure_Policy/PolicyMenuBlade/Definitions

While creating an initiative or policy definition, it is important that you specify the definition location .

Refer the article for more information.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM