|
2 | 2 | title: Guidance for developing Azure Functions |
3 | 3 | description: Learn the Azure Functions concepts and techniques that you need to develop functions in Azure, across all programming languages and bindings. |
4 | 4 | ms.assetid: d8efe41a-bef8-4167-ba97-f3e016fcd39e |
5 | | -ms.topic: conceptual |
6 | | -ms.date: 06/26/2024 |
| 5 | +ms.topic: article |
| 6 | +ms.date: 12/03/2025 |
7 | 7 | ms.custom: |
8 | 8 | - devx-track-extended-java |
9 | 9 | - devx-track-js |
@@ -252,11 +252,14 @@ You need to create a role assignment that provides access to Azure SignalR Servi |
252 | 252 |
|
253 | 253 | An identity-based connection for an Azure service accepts the following common properties, where `<CONNECTION_NAME_PREFIX>` is the value of your `connection` property in the trigger or binding definition: |
254 | 254 |
|
255 | | -| Property | Environment variable template | Description | |
| 255 | +| Property | Environment variable template | Description | |
256 | 256 | |---|---|---| |
257 | | -| Token Credential | `<CONNECTION_NAME_PREFIX>__credential` | Defines how a token should be obtained for the connection. This setting should be set to `managedidentity` if your deployed Azure Function intends to use managed identity authentication. This value is only valid when a managed identity is available in the hosting environment. | |
258 | | -| Client ID | `<CONNECTION_NAME_PREFIX>__clientId` | When `credential` is set to `managedidentity`, this property can be set to specify the user-assigned identity to be used when obtaining a token. The property accepts a client ID corresponding to a user-assigned identity assigned to the application. It's invalid to specify both a Resource ID and a client ID. If not specified, the system-assigned identity is used. This property is used differently in [local development scenarios](#local-development-with-identity-based-connections), when `credential` shouldn't be set. | |
259 | | -| Resource ID | `<CONNECTION_NAME_PREFIX>__managedIdentityResourceId` | When `credential` is set to `managedidentity`, this property can be set to specify the resource Identifier to be used when obtaining a token. The property accepts a resource identifier corresponding to the resource ID of the user-defined managed identity. It's invalid to specify both a resource ID and a client ID. If neither are specified, the system-assigned identity is used. This property is used differently in [local development scenarios](#local-development-with-identity-based-connections), when `credential` shouldn't be set. |
| 257 | +| Token Credential | `<CONNECTION_NAME_PREFIX>__credential` | This property determines how a token should be obtained for the connection. The property shouldn't be set in [local development scenarios]. When you intend to use managed identity authentication, set this property to `managedidentity`. When you intend to [connect to a resource in another tenant][cross-tenant scenarios], instead use `managedidentityasfederatedidentity`. | |
| 258 | +| Client ID | `<CONNECTION_NAME_PREFIX>__clientId` | When `credential` is set to `managedidentity`, this property can be set to specify the user-assigned identity to be used when obtaining a token. The property accepts a client ID corresponding to a user-assigned identity assigned to the application. It's invalid to specify both a resource ID and a client ID. If neither are specified, the system-assigned identity is used.<br/><br/>This property is used differently in cross-tenant scenarios. See the [cross-tenant scenarios] section.<br/><br/>This property is used differently in [local development scenarios], when `credential` shouldn't be set. | |
| 259 | +| Resource ID | `<CONNECTION_NAME_PREFIX>__managedIdentityResourceId` | When `credential` is set to `managedidentity`, this property can be set to specify the user-assigned identity to be used when obtaining a token. The property accepts a resource identifier corresponding to a user-assigned identity assigned to the application. It's invalid to specify both a resource ID and a client ID. If neither are specified, the system-assigned identity is used.| |
| 260 | + |
| 261 | +[local development scenarios]: #local-development-with-identity-based-connections |
| 262 | +[cross-tenant scenarios]: #connecting-to-a-resource-in-another-tenant |
260 | 263 |
|
261 | 264 | Other options may be supported for a given connection type. Refer to the documentation for the component making the connection. |
262 | 265 |
|
@@ -287,7 +290,7 @@ Your identity may already have some role assignments against Azure resources use |
287 | 290 |
|
288 | 291 | In some cases, you may wish to specify use of a different identity. You can add configuration properties for the connection that point to the alternate identity based on a client ID and client Secret for a Microsoft Entra service principal. **This configuration option is not supported when hosted in the Azure Functions service.** To use an ID and secret on your local machine, define the connection with the following extra properties: |
289 | 292 |
|
290 | | -| Property | Environment variable template | Description | |
| 293 | +| Property | Environment variable template | Description | |
291 | 294 | |---|---|---| |
292 | 295 | | Tenant ID | `<CONNECTION_NAME_PREFIX>__tenantId` | The Microsoft Entra tenant (directory) ID. | |
293 | 296 | | Client ID | `<CONNECTION_NAME_PREFIX>__clientId` | The client (application) ID of an app registration in the tenant. | |
@@ -335,6 +338,38 @@ If you're configuring `AzureWebJobsStorage` using a storage account that uses th |
335 | 338 |
|
336 | 339 | [!INCLUDE [functions-azurewebjobsstorage-permissions](../../includes/functions-azurewebjobsstorage-permissions.md)] |
337 | 340 |
|
| 341 | +#### Connecting to a resource in another tenant |
| 342 | + |
| 343 | +If your function needs to connect to a resource in a different Microsoft Entra tenant, your connection needs to use a _federated identity credential_. This requires a user-assigned managed identity and a multi-tenant Entra ID app registration. You cannot use a system-assigned managed identity for cross-tenant connections. |
| 344 | + |
| 345 | +> [!IMPORTANT] |
| 346 | +> When you configure a trigger for a cross-tenant connection in the Consumption or Flex Consumption plan types, the platform no longer scales the function app based on that trigger. |
| 347 | +
|
| 348 | +To configure a cross-tenant identity-based connection, you first need to set up your infrastructure using the following steps: |
| 349 | + |
| 350 | +1. In the tenant where your function app is deployed, [create a new user-assigned managed identity](/entra/identity/managed-identities-azure-resources/how-manage-user-assigned-managed-identities#create-a-user-assigned-managed-identity). |
| 351 | +1. [Assign that identity](../app-service/overview-managed-identity.md?toc=%2Fazure%2Fazure-functions%2Ftoc.json#add-a-user-assigned-identity) to the function app. |
| 352 | +1. In the same tenant, [create a multi-tenant Entra app registration](/entra/workload-id/workload-identity-federation-config-app-trust-managed-identity#configure-a-multi-tenant-app-registration) that represents the cross-tenant resource you want to access. |
| 353 | +1. [Add the managed identity as a federated identity credential for the app registration.](/entra/workload-id/workload-identity-federation-config-app-trust-managed-identity) |
| 354 | +1. In the tenant where the resource is deployed, [create an enterprise application for the app registration](/entra/identity/enterprise-apps/create-service-principal-cross-tenant). |
| 355 | +1. Assign permissions for the enterprise application to access the resource. |
| 356 | + |
| 357 | +A cross-tenant identity-based connection uses the following properties, where `<CONNECTION_NAME_PREFIX>` is the value of your `connection` property in the trigger or binding definition: |
| 358 | + |
| 359 | +| Property | Environment variable template | Description | |
| 360 | +|---|---|---| |
| 361 | +| Token Credential | `<CONNECTION_NAME_PREFIX>__credential` | **Required.** When connecting to a resource in another tenant, set this property to `managedidentityasfederatedidentity`. | |
| 362 | +| Azure Cloud | `<CONNECTION_NAME_PREFIX>__azureCloud` | **Required.** This property determines the Azure cloud environment. Allowed values are "public" for Azure Public Cloud, "usgov" for Azure US Government Cloud, and "china" for Azure operated by 21Vianet. | |
| 363 | +| Client ID | `<CONNECTION_NAME_PREFIX>__clientId` | **Required.** When `credential` is set to `managedidentityasfederatedidentity`, set this property to the client ID (app ID) of the app registration.<br/><br/>This property is used differently in single-tenant identity-based connections. See the [common properties](#common-properties-for-identity-based-connections) section.<br/><br/>This property is used differently in [local development scenarios], when `credential` shouldn't be set. | |
| 364 | +| Tenant ID | `<CONNECTION_NAME_PREFIX>__tenantId` | **Required.** When `credential` is set to `managedidentityasfederatedidentity`, set this property to the tenant ID of the resource tenant.<br/><br/>This property is used differently in [local development scenarios], when `credential` shouldn't be set. | |
| 365 | +| Managed Identity Client ID | `<CONNECTION_NAME_PREFIX>__managedIdentityClientId` | When `credential` is set to `managedidentityasfederatedidentity`, this property specifies the user-assigned identity that you configured as a federated identity credential and assigned to the application.<sup>1</sup> The property accepts a client ID corresponding to that user-assigned identity. | |
| 366 | +| Managed Identity Object ID | `<CONNECTION_NAME_PREFIX>__managedIdentityObjectId` | When `credential` is set to `managedidentityasfederatedidentity`, this property specifies the user-assigned identity that you configured as a federated identity credential and assigned to the application.<sup>1</sup> The property accepts an object ID (principal ID) corresponding to that user-assigned identity. | |
| 367 | +| Managed Identity Resource ID | `<CONNECTION_NAME_PREFIX>__managedIdentityResourceId` | When `credential` is set to `managedidentityasfederatedidentity`, this property specifies the user-assigned identity that you configured as a federated identity credential and assigned to the application.<sup>1</sup> The property accepts a resource identifier corresponding to that user-assigned identity. | |
| 368 | + |
| 369 | +<sup>1</sup> When `credential` is set to `managedidentityasfederatedidentity`, your connection must specify exactly one of `managedIdentityClientId`, `managedIdentityObjectId`, or `managedIdentityResourceId`. |
| 370 | + |
| 371 | +This is also [documented by the Azure SDK](/dotnet/azure/sdk/authentication/create-token-credentials-from-configuration?tabs=client-id#managed-identity-as-a-federated-identity-credential) in a JSON format. |
| 372 | + |
338 | 373 | ## Reporting Issues |
339 | 374 | [!INCLUDE [Reporting Issues](../../includes/functions-reporting-issues.md)] |
340 | 375 |
|
|
0 commit comments