[英]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.