Outputs section in Azure Resource Manager templates

In the Outputs section, you specify values that are returned from deployment. For example, you could return the URI to access a deployed resource.

Define and use output values

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]"
}

Available properties

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.

Recommendations

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"
    }
}

Example templates

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.

Next steps