Skip to content

Commit afb1b49

Browse files
authored
Merge pull request #103866 from tfitzmac/0210resourceid
updated resourceid for scopes
2 parents 489e372 + c51d664 commit afb1b49

File tree

3 files changed

+38
-6
lines changed

3 files changed

+38
-6
lines changed

articles/azure-resource-manager/templates/deploy-to-management-group.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,20 @@ For management group deployments, there are some important considerations when u
5858

5959
* The [resourceGroup()](template-functions-resource.md#resourcegroup) function is **not** supported.
6060
* The [subscription()](template-functions-resource.md#subscription) function is **not** supported.
61-
* The [resourceId()](template-functions-resource.md#resourceid) function is supported. Use it to get the resource ID for resources that are used at management group level deployments. For example, get the resource ID for a policy definition with `resourceId('Microsoft.Authorization/policyDefinitions/', parameters('policyDefinition'))`. It returns the resource ID in the format `/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}`.
6261
* The [reference()](template-functions-resource.md#reference) and [list()](template-functions-resource.md#list) functions are supported.
62+
* The [resourceId()](template-functions-resource.md#resourceid) function is supported. Use it to get the resource ID for resources that are used at management group level deployments. Don't provide a value for the resource group parameter.
63+
64+
For example, to get the resource ID for a policy definition, use:
65+
66+
```json
67+
resourceId('Microsoft.Authorization/policyDefinitions/', parameters('policyDefinition'))
68+
```
69+
70+
The returned resource ID has the following format:
71+
72+
```json
73+
/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
74+
```
6375

6476
## Create policies
6577

articles/azure-resource-manager/templates/deploy-to-subscription.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,22 @@ For each deployment name, the location is immutable. You can't create a deployme
8181
For subscription-level deployments, there are some important considerations when using template functions:
8282

8383
* The [resourceGroup()](template-functions-resource.md#resourcegroup) function is **not** supported.
84-
* The [resourceId()](template-functions-resource.md#resourceid) function is supported. Use it to get the resource ID for resources that are used at subscription level deployments. For example, get the resource ID for a policy definition with `resourceId('Microsoft.Authorization/roleDefinitions/', parameters('roleDefinition'))`. Or, use the [subscriptionResourceId()](template-functions-resource.md#subscriptionresourceid) function to get the resource ID for a subscription level resource.
8584
* The [reference()](template-functions-resource.md#reference) and [list()](template-functions-resource.md#list) functions are supported.
85+
* The [resourceId()](template-functions-resource.md#resourceid) function is supported. Use it to get the resource ID for resources that are used at subscription level deployments. Don't provide a value for the resource group parameter.
86+
87+
For example, to get the resource ID for a policy definition, use:
88+
89+
```json
90+
resourceId('Microsoft.Authorization/roleDefinitions/', parameters('roleDefinition'))
91+
```
92+
93+
The returned resource ID has the following format:
94+
95+
```json
96+
/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
97+
```
98+
99+
Or, use the [subscriptionResourceId()](template-functions-resource.md#subscriptionresourceid) function to get the resource ID for a subscription level resource.
86100

87101
## Create resource groups
88102

articles/azure-resource-manager/templates/template-functions-resource.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Template functions - resources
33
description: Describes the functions to use in an Azure Resource Manager template to retrieve values about resources.
44
ms.topic: conceptual
5-
ms.date: 01/20/2020
5+
ms.date: 02/10/2020
66
---
77
# Resource functions for Azure Resource Manager templates
88

@@ -747,14 +747,14 @@ The preceding example returns an object in the following format:
747747
resourceId([subscriptionId], [resourceGroupName], resourceType, resourceName1, [resourceName2], ...)
748748
```
749749

750-
Returns the unique identifier of a resource. You use this function when the resource name is ambiguous or not provisioned within the same template.
750+
Returns the unique identifier of a resource. You use this function when the resource name is ambiguous or not provisioned within the same template. The format of the returned identifier varies based on whether the deployment happens at the scope of a resource group, subscription, management group, or tenant.
751751

752752
### Parameters
753753

754754
| Parameter | Required | Type | Description |
755755
|:--- |:--- |:--- |:--- |
756756
| subscriptionId |No |string (In GUID format) |Default value is the current subscription. Specify this value when you need to retrieve a resource in another subscription. |
757-
| resourceGroupName |No |string |Default value is current resource group. Specify this value when you need to retrieve a resource in another resource group. |
757+
| resourceGroupName |No |string |Default value is current resource group. Specify this value when you need to retrieve a resource in another resource group. Only provide this value when deploying at the scope of a resource group. |
758758
| resourceType |Yes |string |Type of resource including resource provider namespace. |
759759
| resourceName1 |Yes |string |Name of resource. |
760760
| resourceName2 |No |string |Next resource name segment, if needed. |
@@ -763,7 +763,7 @@ Continue adding resource names as parameters when the resource type includes mor
763763

764764
### Return value
765765

766-
The resource ID is returned in the following format:
766+
When the template is deployed at the scope of a resource group, the resource ID is returned in the following format:
767767

768768
```json
769769
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
@@ -775,6 +775,12 @@ When used in a [subscription-level deployment](deploy-to-subscription.md), the r
775775
/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
776776
```
777777

778+
When used in a [management group-level deployment](deploy-to-management-group.md) or tenant-level deployment, the resource ID is returned in the following format:
779+
780+
```json
781+
/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
782+
```
783+
778784
To get the ID in other formats, see:
779785

780786
* [extensionResourceId](#extensionresourceid)

0 commit comments

Comments
 (0)