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

Sakib Ali Choudhary 225 Reputation points
2024-02-05T14:14:24.31+00:00

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 :- https://learn.microsoft.com/en-us/dotnet/api/azure.ai.openai.azurecognitivesearchchatextensionconfiguration?view=azure-dotnet-preview

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.
1,297 questions
Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
3,463 questions
{count} votes

1 answer

Sort by: Most helpful
  1. brtrach-MSFT 17,731 Reputation points Microsoft Employee Moderator
    2024-02-08T01:32:54.45+00:00

    @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>.vault.azure.net/secrets/<your-search-service-admin-key-name>").ConfigureAwait(false);
    var searchServiceEndpoint = "https://<your-search-service-name>.search.windows.net";
    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

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.