Resource 'azureeventhubtest' was disallowed by policy. (Code: RequestDisallowedByPolicy)

Ranjan Sahoo 0 Reputation points
2025-09-01T15:35:20.7766667+00:00

while creating an event hub using azure sandbox validation error is thrown Resource 'azureeventhubtest' was disallowed by policy. (Code: RequestDisallowedByPolicy) pls find the Raw error below.

{
  "code": "InvalidTemplateDeployment",
  "details": [
    {
      "code": "RequestDisallowedByPolicy",
      "target": "azureeventhubtest",
      "message": "Resource 'azureeventhubtest' was disallowed by policy. Policy identifiers: '[{\"policyAssignment\":{\"name\":\"vm-assignment\",\"id\":\"/providers/Microsoft.Management/managementGroups/1ba712d0-8089-7ba5-e106-fe759dfda658/providers/Microsoft.Authorization/policyAssignments/vm-assignment\"},\"policyDefinition\":{\"name\":\"Allowed resource types\",\"id\":\"/providers/Microsoft.Authorization/policyDefinitions/a08ec900-254a-4555-9bf5-e42af04b5c5c\",\"version\":\"1.0.0\"},\"policySetDefinition\":{\"name\":\"virtualmachines-initiative\",\"id\":\"/providers/Microsoft.Management/managementGroups/learn-sandbox-prod/providers/Microsoft.Authorization/policySetDefinitions/virtualmachines-initiative\",\"version\":\"1.0.0\"}}]'.",
      "additionalInfo": [
        {
          "type": "PolicyViolation",
          "info": {
            "evaluationDetails": {
              "evaluatedExpressions": [
                {
                  "result": "False",
                  "expressionKind": "Field",
                  "expression": "type",
                  "path": "type",
                  "expressionValue": "Microsoft.EventHub/namespaces",
                  "targetValue": [
                    "Microsoft.AlertsManagement/actionRules",
                    "Microsoft.Alertsmanagement/smartDetectorAlertRules",
                    "Microsoft.Compute/availabilitySets",
                    "Microsoft.Compute/disks",
                    "Microsoft.Compute/images",
                    "Microsoft.Compute/sshPublicKeys",
                    "Microsoft.Compute/virtualMachines",
                    "Microsoft.Compute/virtualMachines/extensions",
                    "Microsoft.Compute/virtualMachines/metricDefinitions",
                    "Microsoft.ContainerRegistry/registries",
                    "Microsoft.DataMigration/services",
                    "Microsoft.DataMigration/services/projects",
                    "Microsoft.DBforMySQL/servers",
                    "Microsoft.DBforPostgreSQL/servers",
                    "Microsoft.DocumentDB/databaseAccounts",
                    "Microsoft.Devices/IotHubs",
                    "Microsoft.DevTestLab/schedules",
                    "microsoft.insights/actiongroups",
                    "microsoft.insights/activityLogAlerts",
                    "microsoft.insights/autoscalesettings",
                    "microsoft.insights/alertrules",
                    "microsoft.insights/components",
                    "Microsoft.Insights/dataCollectionRules",
                    "Microsoft.insights/metricalerts",
                    "Microsoft.insights/workbooks",
                    "Microsoft.IoTCentral/IoTApps",
                    "Microsoft.KeyVault/vaults",
                    "Microsoft.KeyVault/vaults/accessPolicies",
                    "Microsoft.KeyVault/vaults/secrets",
                    "Microsoft.Logic/workflows",
                    "Microsoft.Network/applicationGateways",
                    "Microsoft.Network/applicationSecurityGroups",
                    "Microsoft.Network/connections",
                    "Microsoft.Network/dnszones",
                    "Microsoft.Network/dnszones/A",
                    "Microsoft.Network/dnszones/AAA",
                    "Microsoft.Network/dnszones/all",
                    "Microsoft.Network/dnszones/CAA",
                    "Microsoft.Network/dnszones/CNAME",
                    "Microsoft.Network/dnszones/MX",
                    "Microsoft.Network/dnszones/NS",
                    "Microsoft.Network/dnszones/PTR",
                    "Microsoft.Network/dnszones/recordsets",
                    "Microsoft.Network/dnszones/SOA",
                    "Microsoft.Network/dnszones/SRV",
                    "Microsoft.Network/dnszones/TXT",
                    "Microsoft.Network/loadBalancers",
                    "Microsoft.Network/localNetworkGateways",
                    "Microsoft.Network/bastionHosts",
                    "Microsoft.Network/networkInterfaces",
                    "Microsoft.Network/networkSecurityGroups",
                    "Microsoft.Network/networkWatchers",
                    "Microsoft.Network/networkWatchers/connectionMonitors",
                    "Microsoft.Network/networkWatchers/lenses",
                    "Microsoft.Network/networkWatchers/pingMeshes",
                    "Microsoft.Network/publicIPAddresses",
                    "Microsoft.Network/publicIPPrefixes",
                    "Microsoft.Network/routeTables",
                    "Microsoft.Network/routeTables/routes",
                    "Microsoft.Network/trafficmanagerprofiles",
                    "Microsoft.Network/virtualNetworkGateways",
                    "Microsoft.Network/virtualNetworks",
                    "Microsoft.OperationalInsights/workspaces",
                    "Microsoft.OperationsManagement/solutions",
                    "Microsoft.Portal/dashboards",
                    "Microsoft.Resources/deployments",
                    "Microsoft.Resources/resourceGroups",
                    "Microsoft.Security/iotSecuritySolutions",
                    "Microsoft.Sql/servers",
                    "Microsoft.Sql/servers/databases",
                    "Microsoft.Storage/storageAccounts",
                    "Microsoft.StorageSync/storageSyncServices",
                    "Microsoft.Web/connections",
                    "Microsoft.Web/serverFarms",
                    "Microsoft.Web/sites"
                  ],
                  "operator": "In"
                }
              ]
            },
            "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/a08ec900-254a-4555-9bf5-e42af04b5c5c",
            "policySetDefinitionId": "/providers/Microsoft.Management/managementGroups/learn-sandbox-prod/providers/Microsoft.Authorization/policySetDefinitions/virtualmachines-initiative",
            "policyDefinitionReferenceId": "allowed-resource-types_1",
            "policySetDefinitionName": "virtualmachines-initiative",
            "policySetDefinitionDisplayName": "virtualmachines-initiative",
            "policySetDefinitionVersion": "1.0.0",
            "policyDefinitionName": "a08ec900-254a-4555-9bf5-e42af04b5c5c",
            "policyDefinitionDisplayName": "Allowed resource types",
            "policyDefinitionVersion": "1.0.0",
            "policyDefinitionEffect": "deny",
            "policyAssignmentId": "/providers/Microsoft.Management/managementGroups/1ba712d0-8089-7ba5-e106-fe759dfda658/providers/Microsoft.Authorization/policyAssignments/vm-assignment",
            "policyAssignmentName": "vm-assignment",
            "policyAssignmentScope": "/providers/Microsoft.Management/managementGroups/1ba712d0-8089-7ba5-e106-fe759dfda658",
            "policyAssignmentParameters": {},
            "policyExemptionIds": [],
            "policyEnrollmentIds": []
          }
        }
      ]
    }
  ],
  "message": "The template deployment failed because of policy violation. Please see details for more information."
}
Azure Event Hubs
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. TP 145.2K Reputation points Volunteer Moderator
    2025-09-01T15:59:06.5733333+00:00

    Hi Ranjan,

    The sandbox restricts the types of resources that can be created. It is intended to be used for the specific exercises that have sandbox available.

    In your case it appears you are trying to create event hub and that isn't one of the permitted resources for the sandbox you are using.

    As an alternative you may consider using Azure Free account if you are eligible.

    Please click Accept Answer and upvote if the above was helpful.

    Thanks.

    -TP

    0 comments No comments

  2. Pratyush Vashistha 5,045 Reputation points Microsoft External Staff Moderator
    2025-09-04T01:36:19.9766667+00:00

    Hello Ranjan Sahoo! Thanks for posting your query on Microsoft QnA portal.
    Thank you to the community member for the initial response - that's absolutely correct about the sandbox limitations. Let me provide additional technical context and alternative solutions for this Event Hub policy restriction.

    The error "Resource 'azureeventhubtest' was disallowed by policy. (Code: RequestDisallowedByPolicy)"clearly indicates an Azure Policy denying the creation of Event Hub resources in the sandbox subscription due to a policy assignment that restricts allowed resource types (in this case, to virtual machines only). This is a system-level deny assignment implemented to enforce compliance and prevent unauthorized resource types from being created in sandbox or restricted subscriptions.

    As Suggested by our Community champion TP Use a full Azure subscription (such as an Azure Free Account) which does not have these sandbox restrictions, as suggested.

    Or you can try Different Microsoft Learn Sandbox

    Some modules have different policy configurations:

    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    Thanks

    Pratyush


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.