gpt4 book ai didi

Azure 开发测试实验室 : how to parametrize resources

转载 作者:行者123 更新时间:2023-12-03 03:50:42 24 4
gpt4 key购买 nike

我正在尝试创建一个 PowerShell 脚本,该脚本将部署 Azure 开发测试实验室的实例,在那里创建一个环境,以及 databricks、azure 数据工厂等资源。这是我负责的实验室模板的一部分。

       "resources":[
{
"apiVersion":"2018-09-15",
"name":"LabVmsShutdown",
"location":"[parameters('location')]",
"type":"schedules",
"dependsOn":[
"[resourceId('Microsoft.DevTestLab/labs', parameters('labResourceName'))]"
],
"properties":{
"status":"Enabled",
"timeZoneId":"GMT Standard Time",
"dailyRecurrence":{
"time":"0100"
},
"taskType":"LabVmsShutdownTask",
"notificationSettings":{
"status":"Disabled",
"timeInMinutes":30
}
}
},
{
"apiVersion":"2018-09-15",
"name":"[concat('Dtl', parameters('labResourceName'))]",
"type":"virtualNetworks",
"location":"[parameters('location')]",
"dependsOn":[
"[resourceId('Microsoft.DevTestLab/labs', parameters('labResourceName'))]"
]
},
{
"apiVersion":"2018-09-15",
"name":"Public Environment Repo",
"type":"artifactSources",
"location":"[parameters('location')]",
"dependsOn":[
"[resourceId('Microsoft.DevTestLab/labs', parameters('labResourceName'))]"
],
"properties":{
"status":"Enabled"
}
},
{
"apiVersion":"2018-09-15",
"name":"[parameters('repositoryName')]",
"type":"artifactSources",
"dependsOn":[
"[resourceId('Microsoft.DevTestLab/labs', parameters('labResourceName'))]"
],
"properties":{
"uri":"MY_URL",
"armTemplateFolderPath":"MY_PATH",
"displayName":"DevTestLab",
"branchRef":"features/devops-development",
"securityToken":"MY_TOKEN",
"sourceType":"VsoGit",
"status":"Enabled"
}
},
{
"apiVersion":"2018-09-15",
"name":"[parameters('userId')]",
"type":"users",
"location":"[parameters('location')]",
"dependsOn":[
"[resourceId('Microsoft.DevTestLab/labs', parameters('labResourceName'))]"
],
"properties":{
"status":"Enabled"
},
"resources":[
{
"name":"devtestlaab",
"type":"environments",
"apiVersion":"2018-09-15",
"location":"[parameters('location')]",
"properties":{
"deploymentProperties":{
"armTemplateId":"[concat(resourceId('Microsoft.DevTestLab/labs/artifactsources', parameters('labResourceName'), parameters('repositoryName')), '/armTemplates/DevTestLab')]"
},
"armTemplateDisplayName":"DevLab Deployment Script"
},
"dependsOn":[
"[resourceId('Microsoft.DevTestLab/labs/users', parameters('labResourceName'), parameters('userId'))]"
]
}
]
}
]
}
]

它在大多数情况下都运行良好。但是,我无法传递内部模板的参数。它只是在给定时刻获取我的 ref_branch 上这些模板中硬编码的内容并进行部署。

enter image description here

我尝试遵循以下模板并添加参数部分,但它被完全忽略。

{
"name": "string",
"type": "Microsoft.DevTestLab/labs/users/environments",
"apiVersion": "2018-09-15",
"location": "string",
"tags": {},
"properties": {
"deploymentProperties": {
"armTemplateId": "string",
"parameters": [
{
"name": "string",
"value": "string"
}
]
},
"armTemplateDisplayName": "string"
}
}

总而言之,我能够部署:

  • 实验室
  • 环境
  • 本实验室内的资源。

我无法:

  • 将任何参数传递给我的实验室环境中的资源。

文档非常稀缺,所以我不太确定问题可能是什么。

最佳答案

AFAI 了解,您的模板看起来有问题。请查看A quick guide on writing your Azure Resource Manager (ARM) Templates以了解如何使用参数。

并且,对于 PowerShell script deployment ,您可以使用以下命令来部署带有参数的ARM模板:

New-AzResourceGroupDeployment -Name ExampleDeployment -ResourceGroupName ExampleResourceGroup `
-TemplateFile <path-to-template-or-bicep> `
-TemplateParameterFile c:\MyTemplates\storage.parameters.json

或者

New-AzResourceGroupDeployment -Name ExampleDeployment -ResourceGroupName ExampleResourceGroup `
-TemplateUri https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-storage-account-create/azuredeploy.json `
-TemplateParameterUri https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-storage-account-create/azuredeploy.parameters.json

请告诉我这是否有帮助。

关于Azure 开发测试实验室 : how to parametrize resources,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66894407/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com