Home > Net >  AzureKeyCredential for Search via identity.DefaultAzureCredential
AzureKeyCredential for Search via identity.DefaultAzureCredential

Time:10-26

I have a console that is logged into Azure via az login

I can run the follow JavaScript and the console outputs my details as I would expect

const { DefaultAzureCredential } = require("@azure/identity");
const credential = new DefaultAzureCredential();
console.log(credential);

Using the credentials I would like to read the API key from a Search service

So, I can then use the apiKey as follows

indexClient = new SearchIndexClient(searchURL, new AzureKeyCredential(apiKey));

CodePudding user response:

Using the credentials I would like to read the API key from a Search service

To get the admin keys, you will need to use a separate SDK: @azure/arm-search. Once you have created a SearchManagementClient using that SDK and AzureCredentials, you will need to invoke one of the get methods for AdminKeys.

  • Related