Where is the value of deployment().name coming from in Azure Deployment?

Viewed 158

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?

2 Answers

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')]",
    ...
  },
  ...
}
Related