This command creates a policy definition named LocationDefinition that contains the policy rule specified in C:\LocationPolicy.json.
Example content for the LocationPolicy.json file is provided above.
Three file content formats are supported:
1.
Policy rule only (example above).
2.
Policy properties object.
This format is displayed in the portal when editing a policy definition and may include parameters.
3.
Full policy object.
This format is generated by the Azure Policy export function and may include parameters.
Note: Values provided on the command line (e.g.
parameters, metadata) override corresponding values present in the file.
Example 2: Create a parameterized policy definition using inline parameters
This command creates a policy definition named LocationDefinition that contains the policy rule specified in C:\LocationPolicy.json.
The parameter definition for the policy rule is provided inline.
Example 3: Create a policy definition inline in a management group
This command creates a policy definition named VMPolicyDefinition in management group Dept42.
The command specifies the policy as a string in valid JSON format.
Example 4: Create a policy definition inline with metadata
This command creates a policy definition named VMPolicyDefinition with metadata indicating its category is "Virtual Machine".
The command specifies the policy as a string in valid JSON format.
Example 5: Create a policy definition inline with mode
This command creates a policy definition named TagsPolicyDefinition with mode "Indexed" indicating the policy should be evaluated only for resource types that support tags and location.
Parameters
-BackwardCompatible
Causes cmdlet to return artifacts using legacy format placing policy-specific properties in a property bag object.
The DefaultProfile parameter is not functional.
Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable,
-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see
about_CommonParameters.