Configurations which we can do to allow the Use Of Managed Identity for AzureCognitiveSearchChatExtensionConfiguration Class

Sakib Ali Choudhary 180 Reputation points

Hi was just looking at the document's and found that for using the AzureCognitiveSearchChatExtensionConfiguration Class we need to pass on search key and endpoint. But how can we utilize the Azure Managed Identity on it. have tried with key vault. But need some assistance with utilizing this with the Managed Identity.
Ref :-

Azure AI Search
Azure AI Search
An Azure search service with built-in artificial intelligence capabilities that enrich information to help identify and explore relevant content at scale.
608 questions
Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
2,195 questions
{count} votes

1 answer

Sort by: Most helpful
  1. brtrach-MSFT 14,146 Reputation points Microsoft Employee

    @Sakib Ali Choudhary I'll try my best to answer your question based on what you shared You need to create a managed identity for your client application. Then, you need to grant your managed identity access to your search service. Azure Cognitive Search has various built-in roles, and you can also create a custom role. After that, you can use the managed identity to authenticate to Azure Key Vault and retrieve the search service admin key. You can then use this key to create an instance of the AzureCognitiveSearchChatExtensionConfiguration class. Here's an example of how you can use Managed Identity to retrieve the search service admin key:

    var azureServiceTokenProvider = new AzureServiceTokenProvider();
    var keyVaultClient = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(azureServiceTokenProvider.KeyVaultTokenCallback));
    var searchServiceAdminKey = await keyVaultClient.GetSecretAsync("https://<your-key-vault-name><your-search-service-admin-key-name>").ConfigureAwait(false);
    var searchServiceEndpoint = "https://<your-search-service-name>";
    var searchServiceIndexName = "<your-search-service-index-name>";
    var searchServiceQueryApiKey = "<your-search-service-query-api-key>";
    var chatExtensionConfiguration = new AzureCognitiveSearchChatExtensionConfiguration(searchServiceEndpoint, searchServiceIndexName, searchServiceQueryApiKey, searchServiceAdminKey.Value);
    0 comments No comments