Gallery › Azure Arc › Azure Community Policy
Configure Windows Arc-enabled machines to enable Windows Admin Center Extension
Converted Policy DeployIfNotExists Disabled Mode All Version 1.0.1
This policy installs the Windows Admin Center Extension on Azure Arc Enabled Servers
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 166 lines
{
"name": "0e4b8929-3957-46e0-bc05-0e34ce4c5f3e",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Configure Windows Arc-enabled machines to enable Windows Admin Center Extension",
"description": "This policy installs the Windows Admin Center Extension on Azure Arc Enabled Servers",
"metadata": {
"version": "1.0.1",
"category": "Azure Arc"
},
"mode": "All",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy."
},
"allowedValues": [
"DeployIfNotExists",
"Disabled"
],
"defaultValue": "DeployIfNotExists"
},
"port": {
"type": "Integer",
"metadata": {
"displayName": "Port",
"description": "Define the Port on which Windows Admin Center Extension works."
},
"defaultValue": 6516
},
"proxyURL": {
"type": "String",
"metadata": {
"displayName": "Proxy URL",
"description": "Define the Proxy URL. If Proxy URL is empty Proxy URL will NOT be set."
},
"defaultValue": ""
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.HybridCompute/machines"
},
{
"field": "Microsoft.HybridCompute/machines/osName",
"equals": "Windows"
}
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.HybridCompute/machines/extensions",
"roleDefinitionIds": [
"/providers/Microsoft.Authorization/roleDefinitions/cd570a14-e51a-42ad-bac8-bafd67325302"
],
"existenceCondition": {
"allOf": [
{
"field": "Microsoft.HybridCompute/machines/extensions/type",
"equals": "AdminCenter"
},
{
"field": "Microsoft.HybridCompute/machines/extensions/publisher",
"equals": "Microsoft.AdminCenter"
},
{
"field": "Microsoft.HybridCompute/machines/extensions/provisioningState",
"equals": "Succeeded"
}
]
},
"deployment": {
"properties": {
"mode": "incremental",
"parameters": {
"vmName": {
"value": "[field('name')]"
},
"location": {
"value": "[field('location')]"
},
"proxyURL": {
"value": "[parameters('proxyURL')]"
},
"port": {
"value": "[parameters('port')]"
}
},
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"type": "string"
},
"location": {
"type": "string"
},
"proxyURL": {
"type": "string"
},
"port": {
"type": "int"
}
},
"variables": {
"extensionName": "AdminCenter",
"extensionPublisher": "Microsoft.AdminCenter",
"extensionType": "AdminCenter"
},
"resources": [
{
"condition": "[empty(parameters('proxyURL'))]",
"name": "[concat(parameters('vmName'), '/', variables('extensionName'))]",
"type": "Microsoft.HybridCompute/machines/extensions",
"location": "[parameters('location')]",
"apiVersion": "2019-12-12",
"properties": {
"publisher": "[variables('extensionPublisher')]",
"type": "[variables('extensionType')]",
"autoUpgradeMinorVersion": true,
"enableAutomaticUpgrade": true,
"settings": {
"port": "[parameters('port')]",
"proxy": {
"mode": "none"
}
}
}
},
{
"condition": "[not(empty(parameters('proxyURL')))]",
"name": "[concat(parameters('vmName'), '/', variables('extensionName'))]",
"type": "Microsoft.HybridCompute/machines/extensions",
"location": "[parameters('location')]",
"apiVersion": "2019-12-12",
"properties": {
"publisher": "[variables('extensionPublisher')]",
"type": "[variables('extensionType')]",
"autoUpgradeMinorVersion": true,
"enableAutomaticUpgrade": true,
"settings": {
"port": "[parameters('port')]",
"proxy": {
"address": "[toLower(parameters('proxyURL'))]",
"mode": "application"
}
}
}
}
]
}
}
}
}
}
}
}
}Bylaw0e4b8929-3957-46e0-bc05-0e34ce4c5f3e.bylaw.ps1 · 50 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '0e4b8929-3957-46e0-bc05-0e34ce4c5f3e' {
Properties @{
DisplayName = 'Configure Windows Arc-enabled machines to enable Windows Admin Center Extension'
Description = 'This policy installs the Windows Admin Center Extension on Azure Arc Enabled Servers'
Version = '1.0.1'
Category = 'Azure Arc'
Mode = 'All'
}
Parameter Effect @{
AllowedValues = @('DeployIfNotExists', 'Disabled')
Default = 'DeployIfNotExists'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy.'
}
Parameter Port @{
Type = 'Integer'
Default = 6516
DisplayName = 'Port'
Description = 'Define the Port on which Windows Admin Center Extension works.'
}
Parameter ProxyURL @{
Default = ''
DisplayName = 'Proxy URL'
Description = 'Define the Proxy URL. If Proxy URL is empty Proxy URL will NOT be set.'
}
Resource 'Microsoft.HybridCompute/machines' {
Require 'osName is not Windows' {
Field osName | Must -Not -Be 'Windows' -IfPresent
}
}
DeployIfNotExists 'Microsoft.HybridCompute/machines/extensions' -Role 'Azure Connected Machine Resource Administrator' -Effect (Param Effect) {
Require 'type is AdminCenter, publisher is Microsoft.AdminCenter and provisioningState is Succeeded' {
Field 'Microsoft.HybridCompute/machines/extensions/type' | Must -Be 'AdminCenter'
Field publisher | Must -Be 'Microsoft.AdminCenter'
Field provisioningState | Must -Be 'Succeeded'
}
Deployment -TemplateFile './templates/0e4b8929-3957-46e0-bc05-0e34ce4c5f3e.json' -Parameters ([ordered]@{
vmName = (Arm '[field(''name'')]')
location = (Arm '[field(''location'')]')
proxyURL = (Param ProxyURL)
port = (Param Port)
})
}
}Its deployment templates are written beside it:
templates/0e4b8929-3957-46e0-bc05-0e34ce4c5f3e.json
Source: policyDefinitions/Azure Arc/deploy-wac-extension-to-azure-arc-connected-machines/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw