{"id":1817,"date":"2022-02-02T13:23:40","date_gmt":"2022-02-02T21:23:40","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/azure-sdk\/?p=1817"},"modified":"2022-02-02T13:49:13","modified_gmt":"2022-02-02T21:49:13","slug":"introducing-azure-identity-support-in-the-azure-functions-signalr-extension-beta","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/azure-sdk\/introducing-azure-identity-support-in-the-azure-functions-signalr-extension-beta\/","title":{"rendered":"Introducing Azure Identity support in the Azure Functions SignalR extension **Beta**"},"content":{"rendered":"<p>The Azure Functions SignalR extension enables serverless integration with the SignalR Service. We&#8217;re excited to announce the release of version <a href=\"https:\/\/www.nuget.org\/packages\/Microsoft.Azure.WebJobs.Extensions.SignalRService\/1.7.0-beta.1\">1.7.0-beta.1<\/a> for .NET, which introduces Azure Identity integration. The required configuration is similar to what has been discussed for other Function extensions in <a href=\"https:\/\/devblogs.microsoft.com\/azure-sdk\/introducing-the-new-azure-function-extension-libraries-beta\/\">Introducing the new Azure Function extension libraries **Beta**<\/a>.<\/p>\n<h2>Configuration<\/h2>\n<p>With the Identity integration, a Function app can authenticate without providing a connection string in the Function configuration. This post discusses the required configuration in the Azure portal&#8217;s app settings section of your Function app. For more information on configuring app settings for Functions apps, see <a href=\"https:\/\/docs.microsoft.com\/azure\/azure-functions\/functions-how-to-use-azure-function-app-settings?tabs=portal\">Manage your Function app<\/a>.<\/p>\n<h2>General setup<\/h2>\n<p>Unless otherwise specified, each configuration option is powered by the <a href=\"https:\/\/docs.microsoft.com\/dotnet\/api\/overview\/azure\/identity-readme#defaultazurecredential\">DefaultAzureCredential<\/a> type. There are two ways you can configure the Identity connection settings for the SignalR extension:<\/p>\n<ol>\n<li>As part of your Connection setting.<\/li>\n<li>As part of your Endpoints settings.<\/li>\n<\/ol>\n<p>The <a href=\"https:\/\/docs.microsoft.com\/azure\/role-based-access-control\/built-in-roles#signalr-service-owner\">SignalR Service Owner role<\/a> is needed to use an Identity-based connection.<\/p>\n<h3>Connection setting<\/h3>\n<p>You can configure the service URI in a custom connection setting or in the default connection setting <code>AzureSignalRConnectionString<\/code>:<\/p>\n<p><strong>Custom connection setting:<\/strong><\/p>\n<table>\n<thead>\n<tr>\n<th>Name<\/th>\n<th>Value<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>MyConnection__serviceUri<\/code><\/td>\n<td>https:\/\/{SignalRHost}<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Default connection setting:<\/strong><\/p>\n<table>\n<thead>\n<tr>\n<th>Name<\/th>\n<th>Value<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>AzureSignalRConnectionString<\/code><\/td>\n<td>https:\/\/{SignalRHost}<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Here&#8217;s a simple Function that runs when a message is sent from the SignalR Service. This example specifies a custom connection string setting, <code>MyConnection<\/code>, where we&#8217;ve configured the connection information.<\/p>\n<pre><code class=\"language-csharp\">[FunctionName(\"SignalRTriggerFunction\")]\r\npublic static void Run(\r\n    [SignalRTrigger(\"SignalRTest\", \"messages\", \"SendMessage\", ConnectionStringSetting=\"MyConnection\")] InvocationContext invocationContext,\r\n    [SignalRParameter] string message,\r\n    ILogger logger)\r\n{\r\n    logger.LogInformation($\"Receive {message} from {invocationContext.ConnectionId}.\");\r\n}<\/code><\/pre>\n<p><em>You can still use connection string configuration by setting your connection setting to your connection string. This approach is demonstrated in the library&#8217;s <a href=\"https:\/\/github.com\/Azure\/azure-sdk-for-net\/tree\/main\/sdk\/signalr\/Microsoft.Azure.WebJobs.Extensions.SignalRService#authenticate-the-client\">README<\/a>.<\/em><\/p>\n<h3>Multiple endpoints setting<\/h3>\n<p>You can also configure your service URI and other Identity settings per endpoint. The multiple-endpoint feature is only supported on the Persistent transport type.<\/p>\n<table>\n<thead>\n<tr>\n<th>Name<\/th>\n<th>Value<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>Azure__SignalR__Endpoints__eastUs__serviceUri<\/code><\/td>\n<td>https:\/\/{SignalRHost1}<\/td>\n<\/tr>\n<tr>\n<td><code>Azure__SignalR__Endpoints__westUs__serviceUri<\/code><\/td>\n<td>https:\/\/{SignalRHost2}<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>When using multiple-endpoint configuration, the connection setting wouldn&#8217;t be specified in your Function:<\/p>\n<pre><code class=\"language-csharp\">[FunctionName(\"SignalRTriggerFunction\")]\r\npublic static void Run(\r\n    [SignalRTrigger(\"SignalRTest\", \"messages\", \"SendMessage\")] InvocationContext invocationContext,\r\n    [SignalRParameter] string message,\r\n    ILogger logger)\r\n{\r\n    logger.LogInformation($\"Receive {message} from {invocationContext.ConnectionId}.\");\r\n}<\/code><\/pre>\n<p>For more information, see <a href=\"https:\/\/github.com\/Azure\/azure-sdk-for-net\/blob\/main\/sdk\/signalr\/Microsoft.Azure.WebJobs.Extensions.SignalRService\/docs\/sharding.md\">Multiple Azure SignalR Service Instances Support in Azure Functions<\/a>.<\/p>\n<h3>Advanced configuration<\/h3>\n<p>In each of the preceding examples, the <a href=\"https:\/\/docs.microsoft.com\/dotnet\/api\/overview\/azure\/identity-readme#defaultazurecredential\">DefaultAzureCredential<\/a> type would be used by the extensions to attempt to authenticate with the service. It&#8217;s also possible to configure more fine-grained authentication. We&#8217;ll use the connection setting approach as an example. The same settings are available when using the endpoints setting.<\/p>\n<p>To configure using Managed Identity, which uses the <a href=\"https:\/\/docs.microsoft.com\/dotnet\/api\/azure.identity.managedidentitycredential?view=azure-dotnet\">ManagedIdentityCredential<\/a> type:<\/p>\n<table>\n<thead>\n<tr>\n<th>Name<\/th>\n<th>Value<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>MyConnection__serviceUri<\/code><\/td>\n<td>https:\/\/{SignalRHost}<\/td>\n<\/tr>\n<tr>\n<td><code>MyConnection__credential<\/code><\/td>\n<td>managedIdentity<\/td>\n<\/tr>\n<tr>\n<td><code>MyConnection__clientId<\/code><\/td>\n<td>{myClientId}<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>To configure using a client secret credential, which uses the <a href=\"https:\/\/docs.microsoft.com\/dotnet\/api\/azure.identity.clientsecretcredential?view=azure-dotnet\">ClientSecretCredential<\/a> type:<\/p>\n<table>\n<thead>\n<tr>\n<th>Name<\/th>\n<th>Value<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>MyConnection__serviceUri<\/code><\/td>\n<td>https:\/\/{SignalRHost}<\/td>\n<\/tr>\n<tr>\n<td><code>MyConnection__tenantId<\/code><\/td>\n<td>{myTenantId}<\/td>\n<\/tr>\n<tr>\n<td><code>MyConnection__clientId<\/code><\/td>\n<td>{myClientId}<\/td>\n<\/tr>\n<tr>\n<td><code>MyConnection__clientSecret<\/code><\/td>\n<td>{myClientSecret}<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>And finally, to configure using a client certificate, which uses the <a href=\"https:\/\/docs.microsoft.com\/dotnet\/api\/azure.identity.clientcertificatecredential?view=azure-dotnet\">ClientCertificateCredential<\/a> type:<\/p>\n<table>\n<thead>\n<tr>\n<th>Name<\/th>\n<th>Value<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>MyConnection__serviceUri<\/code><\/td>\n<td>https:\/\/{SignalRHost}<\/td>\n<\/tr>\n<tr>\n<td><code>MyConnection__tenantId<\/code><\/td>\n<td>{myTenantId}<\/td>\n<\/tr>\n<tr>\n<td><code>MyConnection__clientId<\/code><\/td>\n<td>{myClientId}<\/td>\n<\/tr>\n<tr>\n<td><code>MyConnection__certificate<\/code><\/td>\n<td>{myCertificateThumbprint}<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Conclusion<\/h2>\n<p>The Functions SignalR extension enables serverless integration with the SignalR Service. By using Azure Active Directory configuration, you can avoid deploying secrets along with your app.<\/p>\n<p>For more information about the Functions SignalR extension, see the <a href=\"https:\/\/github.com\/Azure\/azure-sdk-for-net\/blob\/main\/sdk\/signalr\/Microsoft.Azure.WebJobs.Extensions.SignalRService\/README.md\">README<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Azure Identity support has arrived in the Azure Functions SignalR Service extension&#8217;s 1.7.0 Beta 1 release.<\/p>\n","protected":false},"author":55909,"featured_media":1815,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[701,765,841,24,856],"class_list":["post-1817","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure-sdk","tag-net","tag-azure-functions","tag-azure-identity","tag-releases","tag-signalr"],"acf":[],"blog_post_summary":"<p>Azure Identity support has arrived in the Azure Functions SignalR Service extension&#8217;s 1.7.0 Beta 1 release.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/posts\/1817","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/users\/55909"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/comments?post=1817"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/posts\/1817\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/media\/1815"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/media?parent=1817"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/categories?post=1817"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sdk\/wp-json\/wp\/v2\/tags?post=1817"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}