Skip to content

Commit a56da99

Browse files
Merge pull request #282024 from JialinXin/patch-6
Update signalr-howto-authorize-managed-identity.md
2 parents e28f0f8 + 9e36fc2 commit a56da99

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

articles/azure-signalr/signalr-howto-authorize-managed-identity.md

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Authorize requests to Azure SignalR Service resources with Microsoft Entr
33
description: This article provides information about authorizing requests to Azure SignalR Service resources by using Microsoft Entra managed identities.
44
author: vicancy
55
ms.author: lianwei
6-
ms.date: 03/28/2023
6+
ms.date: 07/28/2024
77
ms.service: signalr
88
ms.topic: how-to
99
ms.devlang: csharp
@@ -76,9 +76,18 @@ To learn more about how to assign and manage Azure roles, see these articles:
7676

7777
#### Use a system-assigned identity
7878

79-
You can use either [DefaultAzureCredential](/dotnet/api/overview/azure/identity-readme#defaultazurecredential) or [ManagedIdentityCredential](/dotnet/api/azure.identity.managedidentitycredential) to configure your Azure SignalR Service endpoints. The best practice is to use `ManagedIdentityCredential` directly.
79+
Azure SignalR SDK supports identity based connection string. If the configuration is set in App Server's environment variables, you don't need to redeploy App Server but simply a configuration change to migrate from Access Key to MSI. For example, update your App Server's environment variable `Azure__SignalR__ConnectionString` to `Endpoint=https://<resource1>.service.signalr.net;AuthType=azure.msi;Version=1.0;`. Or set in DI code.
8080

81-
The system-assigned managed identity is used by default, but *make sure that you don't configure any environment variables* that [EnvironmentCredential](/dotnet/api/azure.identity.environmentcredential) preserved if you use `DefaultAzureCredential`. Otherwise, Azure SignalR Service falls back to use `EnvironmentCredential` to make the request, which usually results in an `Unauthorized` response.
81+
```C#
82+
services.AddSignalR().AddAzureSignalR("Endpoint=https://<resource1>.service.signalr.net;AuthType=azure.msi;Version=1.0;");
83+
```
84+
85+
Besides, you can use either [DefaultAzureCredential](/dotnet/api/overview/azure/identity-readme#defaultazurecredential) or [ManagedIdentityCredential](/dotnet/api/azure.identity.managedidentitycredential) to configure your Azure SignalR Service endpoints. The best practice is to use `ManagedIdentityCredential` directly.
86+
87+
Notice that system-assigned managed identity is used by default, but *make sure that you don't configure any environment variables* that [EnvironmentCredential](/dotnet/api/azure.identity.environmentcredential) preserved if you use `DefaultAzureCredential`. Otherwise, Azure SignalR Service falls back to use `EnvironmentCredential` to make the request, which usually results in an `Unauthorized` response.
88+
89+
> [!IMPORTANT]
90+
> Remove `Azure__SignalR__ConnectionString` if there was from environment variables in this way. `Azure__SignalR__ConnectionString` will be used to build default `ServiceEndpoint` with first priority and may leads your App Server use Access Key unexpectedly.
8291
8392
```C#
8493
services.AddSignalR().AddAzureSignalR(option =>
@@ -97,16 +106,26 @@ Provide `ClientId` while creating the `ManagedIdentityCredential` object.
97106
> [!IMPORTANT]
98107
> Use the client ID, not the object (principal) ID, even if they're both GUIDs.
99108
109+
Use identity based connection string.
110+
111+
```C#
112+
services.AddSignalR().AddAzureSignalR("Endpoint=https://<resource1>.service.signalr.net;AuthType=azure.msi;ClientId=<your-user-identity-client-id>;Version=1.0;");
113+
```
114+
115+
Or build `ServiceEndpoint` with `ManagedIdentityCredential`.
116+
100117
```C#
101118
services.AddSignalR().AddAzureSignalR(option =>
102119
{
103120
option.Endpoints = new ServiceEndpoint[]
104121
{
105-
var clientId = "<your identity client id>";
122+
var clientId = "<your-user-identity-client-id>";
106123
new ServiceEndpoint(new Uri("https://<resource1>.service.signalr.net"), new ManagedIdentityCredential(clientId)),
107124
};
125+
});
108126
```
109127

128+
110129
### Azure SignalR Service bindings in Azure Functions
111130

112131
Azure SignalR Service bindings in Azure Functions use [application settings](../azure-functions/functions-how-to-use-azure-function-app-settings.md) in the portal or [local.settings.json](../azure-functions/functions-develop-local.md#local-settings-file) locally to configure a managed identity to access your Azure SignalR Service resources.

0 commit comments

Comments
 (0)