Gallery › Custom Provider › Azure built-in policies
[Deprecated]: Deploy associations for a custom provider
Converted Policy DeployIfNotExists Disabled Mode Indexed Version 1.1.0-deprecated Deprecated
This policy is deprecated because Azure Custom Providers will be retired on October 31, 2026. For more information, see https://learn.microsoft.com/azure/azure-resource-manager/custom-providers/overview. Deploys an association resource that associates selected resource types to the specified custom provider. This policy deployment does not support nested resource types.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
{
"properties": {
"displayName": "[Deprecated]: Deploy associations for a custom provider",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "This policy is deprecated because Azure Custom Providers will be retired on October 31, 2026. For more information, see https://learn.microsoft.com/azure/azure-resource-manager/custom-providers/overview. Deploys an association resource that associates selected resource types to the specified custom provider. This policy deployment does not support nested resource types.",
"metadata": {
"version": "1.1.0-deprecated",
"category": "Custom Provider",
"deprecated": true
},
"version": "1.1.0",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
},
"allowedValues": [
"DeployIfNotExists",
"Disabled"
],
"defaultValue": "Disabled"
},
"targetCustomProviderId": {
"type": "String",
"metadata": {
"displayName": "Custom provider ID",
"description": "Resource ID of the Custom provider to which resources need to be associated."
}
},
"resourceTypesToAssociate": {
"type": "Array",
"metadata": {
"displayName": "Resource types to associate",
"description": "The list of resource types to be associated to the custom provider.",
"strongType": "resourceTypes"
}
},
"associationNamePrefix": {
"type": "String",
"metadata": {
"displayName": "Association name prefix",
"description": "Prefix to be added to the name of the association resource being created."
},
"defaultValue": "DeployedByPolicy"
}
},
"policyRule": {
"if": {
"field": "type",
"in": "[parameters('resourceTypesToAssociate')]"
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.CustomProviders/Associations",
"name": "[concat(parameters('associationNamePrefix'), '-', uniqueString(parameters('targetCustomProviderId')))]",
"roleDefinitionIds": [
"/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"
],
"deployment": {
"properties": {
"mode": "incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"associatedResourceName": {
"type": "string"
},
"resourceTypesToAssociate": {
"type": "string"
},
"targetCustomProviderId": {
"type": "string"
},
"associationNamePrefix": {
"type": "string"
}
},
"variables": {
"resourceType": "[concat(parameters('resourceTypesToAssociate'), '/providers/associations')]",
"resourceName": "[concat(parameters('associatedResourceName'), '/microsoft.customproviders/', parameters('associationNamePrefix'), '-', uniqueString(parameters('targetCustomProviderId')))]"
},
"resources": [
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2017-05-10",
"name": "[concat(deployment().Name, '-2')]",
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "[variables('resourceType')]",
"name": "[variables('resourceName')]",
"apiVersion": "2018-09-01-preview",
"properties": {
"targetResourceId": "[parameters('targetCustomProviderId')]"
}
}
]
}
}
}
]
},
"parameters": {
"resourceTypesToAssociate": {
"value": "[field('type')]"
},
"associatedResourceName": {
"value": "[field('name')]"
},
"targetCustomProviderId": {
"value": "[parameters('targetCustomProviderId')]"
},
"associationNamePrefix": {
"value": "[parameters('associationNamePrefix')]"
}
}
}
}
}
}
},
"versions": [
"1.1.0",
"1.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/c15c281f-ea5c-44cd-90b8-fc3c14d13f0c",
"name": "c15c281f-ea5c-44cd-90b8-fc3c14d13f0c"
}# Converted from AssociationForCustomProvider_DINE.json by ConvertTo-Bylaw.
Policy 'c15c281f-ea5c-44cd-90b8-fc3c14d13f0c' {
Properties @{
DisplayName = '[Deprecated]: Deploy associations for a custom provider'
Description = 'This policy is deprecated because Azure Custom Providers will be retired on October 31, 2026. For more information, see https://learn.microsoft.com/azure/azure-resource-manager/custom-providers/overview. Deploys an association resource that associates selected resource types to the specified custom provider. This policy deployment does not support nested resource types.'
Version = '1.1.0-deprecated'
Category = 'Custom Provider'
Deprecated = $true
PolicyVersion = '1.1.0'
Mode = 'Indexed'
}
Parameter Effect @{
AllowedValues = @('DeployIfNotExists', 'Disabled')
Default = 'Disabled'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Parameter TargetCustomProviderId @{
Type = 'String'
DisplayName = 'Custom provider ID'
Description = 'Resource ID of the Custom provider to which resources need to be associated.'
}
Parameter ResourceTypesToAssociate @{
Type = 'Array'
DisplayName = 'Resource types to associate'
Description = 'The list of resource types to be associated to the custom provider.'
Metadata = [ordered]@{ strongType = 'resourceTypes' }
}
Parameter AssociationNamePrefix @{
Default = 'DeployedByPolicy'
DisplayName = 'Association name prefix'
Description = 'Prefix to be added to the name of the association resource being created.'
}
Resource * {
Require 'type is not one of the ResourceTypesToAssociate parameter' {
Field type | Must -Not -BeIn (Param ResourceTypesToAssociate) -IfPresent
}
}
DeployIfNotExists 'Microsoft.CustomProviders/Associations' -Role 'Contributor' -Name (Arm '[concat(parameters(''associationNamePrefix''), ''-'', uniqueString(parameters(''targetCustomProviderId'')))]') -Effect (Param Effect) {
Deployment -TemplateFile './templates/c15c281f-ea5c-44cd-90b8-fc3c14d13f0c.json' -Parameters ([ordered]@{
resourceTypesToAssociate = (Arm '[field(''type'')]')
associatedResourceName = (Arm '[field(''name'')]')
targetCustomProviderId = (Param TargetCustomProviderId)
associationNamePrefix = (Param AssociationNamePrefix)
})
}
}Its deployment templates are written beside it:
templates/c15c281f-ea5c-44cd-90b8-fc3c14d13f0c.json
Source: built-in-policies/policyDefinitions/Custom Provider/AssociationForCustomProvider_DINE.json in Azure/azure-policy, under the MIT licence.
Bylaw