Azure Policy on Azure Stack Hub

James Churches 96 Reputation points
2021-02-26T05:12:28.77+00:00

Is Azure Policy supported on Azure Stack Hub?

I'm trying to apply a policy using this data:

{
    "policies": [
        {
            "name": "enforceAllowedVMImages",
            "description": "Policy to enforce the use of specific VM Images",
            "parameters": {
                "imageIds": {
                    "type": "array",
                    "metadata": {
                        "description": "The list of allowed VM Images.",
                        "displayName": "Allowed VM Images"
                    }
                }
            },
            "rules": {
                "if": {
                    "allOf": [
                        {
                            "field": "type",
                            "equals": "Microsoft.Compute/virtualMachines"
                        },
                        {
                            "not": {
                                "field": "Microsoft.Compute/imageId",
                                "in": "[parameters('imageIds')]"
                            }
                        }
                    ]
                },
                "then": {
                    "effect": "audit"
                }
            }
        }
    ]
 }

When using PowerShell (New-AzPolicyDefinition) to create the above policy definition I get the following error:

New-AzPolicyDefinition : InvalidProviderNameInPolicyAlias : The policy definition 'enforceAllowedVMImages' rule is invalid. The provider 'Microsoft.Compute' referenced by the 'field' property 'Microsoft.Compute/imageId' of the policy rule doesn't exist.

The Micosoft.Computer provider clearly exists .... so I don't understand the error. I get similar errors for any other policy definition I try to apply that has a provider in the policy definition. The few policy definitions I have that don't have a provider in them work okay.

The same policy definition works okay against Azure public, so I am wondering if I'm trying to do something that is not supported on Azure Stack Hub?

Azure Stack Hub
Azure Stack Hub
An extension of Azure for running apps in an on-premises environment and delivering Azure services in a datacenter.
181 questions
Azure Policy
Azure Policy
An Azure service that is used to implement corporate governance and standards at scale for Azure resources.
815 questions
{count} votes

0 additional answers

Sort by: Most helpful