通过参数在arm模板中部署Autoscale配置文件 [英] Deploying Autoscale profiles in an arm template via parameters

查看:101
本文介绍了通过参数在arm模板中部署Autoscale配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将自动缩放配置文件放入参数文件中,以便在我的arm模板中使用。我将它们放在参数中,以便我可以自定义每个环境的配置文件。但是,我遇到了如何处理
metricResourceUri的问题。 在主模板中,我首先部署应用服务计划,然后部署自动缩放设置。我可以从arm模板中的第一个部署中引用resourceid,但我不确定如何在参数文件中执行此操作。


有没有办法做一些像使用参数文件中的参考函数就像你可以在主模板中一样?关于如何实现这一目标的任何建议或想法?



参数文件中有问题的属性

" rules" ;: [
{
" metricTrigger":{
" metricResourceUri":"< app service of app service计划>"
}
}
]

精简版手臂模板

 {
< appServiceDeployment>
},
{
" type":" Microsoft.Resources / deployments",
" dependsOn":[
" [variables('appServiceDeployment ")]"
]
" properties" ;: {
" mode":" Incremental",
" resources":[
{
" name":" autoscale",
" type":" Microsoft.Insights / autoscalesettings",
" apiVersion":" 2015-04-01",
" location":" [resourceGroup()。location]",
" tags":{},
" properties":{
" profiles":" [parameters ('autoScaleProfiles')]",
" enabled":true,
" targetResourceUri":" [reference('('appServiceDeployment'))。outputs.appServicePlanResourceId.value]"
}
}
]
}
}
}



解决方案

嗨Jose,


基于这个
文档
,由于参数文件包含参数的值,因此在部署期间会自动将值传递给模板。您可以创建多个参数文件,然后传入方案的相应参数文件。您还可以使用变量来链接模板并从链接模板中获取值。 您可以创建一个静态变量,用于存储主模板的基本URL,然后从该基本URL动态创建链接模板的URL。这种
方法的好处是您可以轻松移动或分叉模板,因为您只需要更改主模板中的静态变量。主模板在整个分解模板中传递正确的URI。


您还可以使用deployment()获取当前模板的基本URL,并使用它来获取其他模板的URL在同一个地方。请参阅此

文档
,了解有关如何实现此目的的更多信息。


示例:

 "变量":{
" sharedTemplateUrl":" [uri(deployment()。properties.templateLink.uri,'shared-resources.json')]"
}





I'm attempting to put autoscale profiles into a parameters file for use in my arm template. I am placing them in parameters so I can customize the profiles per environment. However, I am running into an issue with how to handle the metricResourceUri. In the main template, I am deploying the app service plan first, then the autoscaling settings. I can reference the resourceid from the first deployment within the arm template, but I'm not sure how to do that in the parameters file.

Is there a way to do something like use the reference function in the parameters file like you can in the main template? Any suggestions or ideas on how to accomplish this?

Problematic property in the parameters file

"rules": [
  {
	"metricTrigger": {
	  "metricResourceUri": "<resource id of app service plan>"
	}
  }
]

Condensed version of the arm template

{
      <appServiceDeployment>
},
{
      "type": "Microsoft.Resources/deployments",
      "dependsOn": [
        "[variables('appServiceDeployment')]"
      ]
      "properties": {
        "mode": "Incremental",
          "resources": [
            {
              "name": "autoscale",
              "type": "Microsoft.Insights/autoscalesettings",
              "apiVersion": "2015-04-01",
              "location": "[resourceGroup().location]",
              "tags": {},
              "properties": {
                "profiles": "[parameters('autoScaleProfiles')]",
                "enabled": true,
                "targetResourceUri": "[reference(variables('appServiceDeployment')).outputs.appServicePlanResourceId.value]"
              }
            }
          ]
        }
      }
    }


解决方案

Hi Jose,

Based on this documentation, since the parameter file contains a value for the parameter, the value is automatically passed to the template during deployment. You can create more than one parameter file, and then pass in the appropriate parameter file for the scenario.you can also use variables to link templates and get values from linked template.  You can create a static variable that stores a base URL for the main template and then dynamically create URLs for the linked templates from that base URL. The benefit of this approach is you can easily move or fork the template because you only need to change the static variable in the main template. The main template passes the correct URIs throughout the decomposed template.

You can also use deployment() to get the base URL for the current template, and use that to get the URL for other templates in the same location. Please see this documentation for more information on how to achieve this.

Example:

"variables": {
    "sharedTemplateUrl": "[uri(deployment().properties.templateLink.uri, 'shared-resources.json')]"
}



这篇关于通过参数在arm模板中部署Autoscale配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆