[英]Dynamically get the value of management group id during arm template deployment
[英]How to give default value to resource group field in ARM template deployment?
我有下面给出的示例 ARM 模板。 字段订阅、资源组和位置在第一部分 ARM 模板中提供给用户,同时部署和参数部分在此之后提供。 资源组是由 Azure ARM 本身提供的下拉字段,我需要在其中提供任何一个资源组作为列表中存在的默认资源组。 这怎么可能?
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"writePermission": {
"defaultValue": "No",
"allowedValues": [
"No",
"Yes"
],
"type": "String",
"metadata": {
"description": "the permission type"
}
}
},
"variables": {
"location": "[resourceGroup().location]",
"templateUri": "[deployment().properties.templateLink.uri]"
},
"resources": [
],
"outputs": {
"result": {
"type": "String",
"value": "[variables('templateUri')]"
}
}
}
这就是模板的呈现方式。
预期的解决方案:而不是资源组中的空白值,它应该预先填充资源组下拉列表中的第一个字段。
具有 ARM 模板的部署始终在模板外部提供部署资源组。 部署始终基于您作为模板外部参数提供的资源组。 使用 PS 部署的命令的名称是:New-AzResourceGroupDeployment,表示您将提供的资源组作为基础,选择资源组的参数名为:-ResourceGroup
所以基本上你不能在你的 ARM 模板中选择基本资源组,因为它在外部提供给 API 知道从哪里开始部署。
这是执行部署的 PS 命令:
New-AzResourceGroupDeployment
[-Name <String>]
-ResourceGroupName <String>
[-Mode <DeploymentMode>]
[-DeploymentDebugLogLevel <String>]
[-RollbackToLastDeployment]
[-RollBackDeploymentName <String>]
[-Tag <Hashtable>]
[-WhatIfResultFormat <WhatIfResultFormat>]
[-WhatIfExcludeChangeType <String[]>]
[-Force]
[-AsJob]
-TemplateFile <String>
[-SkipTemplateParameterPrompt]
[-ApiVersion <String>]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
PS命令使用ARM Rest API,它是API使用的883587606064488 PORTAL。
https://learn.microsoft.com/en-us/rest/api/resources/deployments/createorupdate
所以我要说的是,您不能使用模板来操作基本资源组的下拉框,唯一可以做到这一点的方法是使用 RBAC 限制用户的访问权限,以便用户只能查看用户应该能够部署到的资源组。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.