title | description | services | documentationcenter | author | manager | editor | ms.service | ms.devlang | ms.topic | ms.tgt_pltfrm | ms.workload | ms.date | ms.author |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Azure Resource Manager template outputs | Microsoft Docs |
Describes how to define outputs for an Azure Resource Manager templates using declarative JSON syntax. |
azure-resource-manager |
na |
tfitzmac |
timlt |
tysonn |
azure-resource-manager |
na |
conceptual |
na |
na |
12/14/2017 |
tomfitz |
In the Outputs section, you specify values that are returned from deployment. For example, you could return the URI to access a deployed resource.
The following example shows how to return the resource ID for a public IP address:
"outputs": {
"resourceID": {
"type": "string",
"value": "[resourceId('Microsoft.Network/publicIPAddresses', parameters('publicIPAddresses_name'))]"
}
}
After the deployment, you can retrieve the value with script. For PowerShell, use:
(Get-AzureRmResourceGroupDeployment -ResourceGroupName <resource-group-name> -Name <deployment-name>).Outputs.resourceID.value
For Azure CLI, use:
az group deployment show -g <resource-group-name> -n <deployment-name> --query properties.outputs.resourceID.value
You can retrieve the output value from a linked template by using the reference function. To get an output value from a linked template, retrieve the property value with syntax like: "[reference('<name-of-deployment>').outputs.<property-name>.value]"
.
For example, you can set the IP address on a load balancer by retrieving a value from a linked template.
"publicIPAddress": {
"id": "[reference('linkedTemplate').outputs.resourceID.value]"
}
You cannot use the reference
function in the outputs section of a nested template. To return the values for a deployed resource in a nested template, convert your nested template to a linked template.
The following example shows the structure of an output definition:
"outputs": {
"<outputName>" : {
"type" : "<type-of-output-value>",
"value": "<output-value-expression>"
}
}
Element name | Required | Description |
---|---|---|
outputName | Yes | Name of the output value. Must be a valid JavaScript identifier. |
type | Yes | Type of the output value. Output values support the same types as template input parameters. |
value | Yes | Template language expression that is evaluated and returned as output value. |
If you use a template to create public IP addresses, include an outputs section that returns details of the IP address and the fully qualified domain name (FQDN). You can use output values to easily retrieve details about public IP addresses and FQDNs after deployment.
"outputs": {
"fqdn": {
"value": "[reference(parameters('publicIPAddresses_name')).dnsSettings.fqdn]",
"type": "string"
},
"ipaddress": {
"value": "[reference(parameters('publicIPAddresses_name')).ipAddress]",
"type": "string"
}
}
Template | Description |
---|---|
Copy variables | Creates complex variables and outputs those values. Does not deploy any resources. |
Public IP address | Creates a public IP address and outputs the resource ID. |
Load balancer | Links to the preceding template. Uses the resource ID in the output when creating the load balancer. |
- To view complete templates for many different types of solutions, see the Azure Quickstart Templates.
- For details about the functions you can use from within a template, see Azure Resource Manager Template Functions.
- To combine multiple templates during deployment, see Using linked templates with Azure Resource Manager.
- You may need to use resources that exist within a different resource group. This scenario is common when working with storage accounts or virtual networks that are shared across multiple resource groups. For more information, see the resourceId function.