Azure 部署中的deployment().name 值来自哪里?

发布于 2025-01-09 17:12:18 字数 1156 浏览 2 评论 0 原文

作为模板文件的一部分,我们有一个由 deployment 方法的deployment().name,与此类似:

"myVariable": "[concat(SOME_CUSTOM_STRING_HERE, deployment().name)]"

变量是 then用作我们的经典云服务资源的部署标签,其中包括内部版本号。

{
  "apiVersion": "2015-12-01",
  "type": "deploymentSlots",
  "name": "staging",
  "properties": {
    "deploymentLabel": "[variables('myVariable')]",
    ...
  },
  ...
}

也许deployment().name可以由Azure设置而不是定义,但我一直无法找到它。

但是,在云服务扩展支持下,该变量的值有所不同。这次,该值是一个长哈希值和云服务资源的名称,尽管定义仍然如上所示。该变量在标签中使用:

{
  "apiVersion": "2021-03-01",
  "type": "Microsoft.Compute/cloudServices",
  "name": "RESOURCE_NAME",
  "location": "[LOCATION]",
  "tags": {
    "DeploymentLabel": "[variables('myVariable')]",
    ...
  },
  ...
}

那么部署云服务的扩展支持版本时,deployment().name 模板函数的值是否发生变化?如果不能的话可以设置吗?如何设置?

As part of our template files, we have a variable defined partially by deployment method's deployment().name, similar to this:

"myVariable": "[concat(SOME_CUSTOM_STRING_HERE, deployment().name)]"

The variable is then used as the deployment label for our Classic Cloud Service resources which includes the build number.

{
  "apiVersion": "2015-12-01",
  "type": "deploymentSlots",
  "name": "staging",
  "properties": {
    "deploymentLabel": "[variables('myVariable')]",
    ...
  },
  ...
}

Perhaps deployment().name can be set and not defined by Azure, but I haven't been able I haven't been able to find it.

However, the variable's value is different under Cloud Service Extended Support. This time the value is a long hash and the name of the Cloud Service resource, even thought the definition remains as shown above. The variable is used in a tag:

{
  "apiVersion": "2021-03-01",
  "type": "Microsoft.Compute/cloudServices",
  "name": "RESOURCE_NAME",
  "location": "[LOCATION]",
  "tags": {
    "DeploymentLabel": "[variables('myVariable')]",
    ...
  },
  ...
}

So did the value of deployment().name template function change for deployments of Extended Support version of cloud service? If not, can it be set and how?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦境 2025-01-16 17:12:18

从 Azure Devops 端来看,如果您正在运行部署,则任务本身具有部署名称,例如部署模式。如果未提供,则会自动生成

部署模式:'增量'
部署名称:“部署名称”

如果是 powershell,请检查下面的链接
https: //learn.microsoft.com/en-us/azure/azure-resource-manager/templates/deploy-cli#azure-deployment-template-name

From the Azure Devops side, if you are running the deployment the task itself has the deployment name like deployment mode. if its not provided, automatically it gets generated

deploymentMode: 'Incremental'
deploymentName: 'deploymentname'

if its powershell then please check the link below
https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/deploy-cli#azure-deployment-template-name

×纯※雪 2025-01-16 17:12:18

您在部署资源时设置名称:

{
  "apiVersion": "2021-03-01",
  "type": "Microsoft.Compute/cloudServices",
"NAME": "MYRESOURCE",
  "location": "[LOCATION]",
  "tags": {
    "DeploymentLabel": "[variables('myVariable')]",
    ...
  },
  ...
}

you set the name when you deploy a resource:

{
  "apiVersion": "2021-03-01",
  "type": "Microsoft.Compute/cloudServices",
"NAME": "MYRESOURCE",
  "location": "[LOCATION]",
  "tags": {
    "DeploymentLabel": "[variables('myVariable')]",
    ...
  },
  ...
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文