Search code examples
azurepowershellazure-cognitive-search

Hot to get Azure Search Service query key


I need list query keys from Microsoft.Search/searchServices using PoweShell or API. What I have investigate till now is:

Get-AzureRmResource -ResourceType "Microsoft.Search/searchServices/listQueryKeys" -ResourceGroupName 'resource-group-name' -ResourceName 'resource-name' -ApiVersion '2015-08-19' 

Returns the array of objects with only names:

@{Name=a}
@{Name=query-key-created-from-powershell}

I have not found the API to get query keys. There is easy way to get admin key:

Invoke-AzureRmResourceAction -Action listAdminKeys -ResourceType "Microsoft.Search/searchServices" -ResourceGroupName 'resource-group-name' -ResourceName 'resource-name' -ApiVersion 2015-08-19

But no way I can get QueryKeys. This is not working:

Invoke-AzureRmResourceAction -Action listQueryKeys -ResourceType "Microsoft.Search/searchServices" -ResourceGroupName 'resource-group-name' -ResourceName 'resource-name' -ApiVersion 2015-08-19

The docs refer only to create or delete Query Key. How can I get Query Keys as name-key collection?


Solution

  • Try to use the following cmdlet:

    Get-AzureRmSearchQueryKey -ResourceGroupName "resourceGroupName" -ServiceName "serviceName"
    

    https://learn.microsoft.com/en-US/powershell/module/azurerm.search/get-azurermsearchquerykey?view=azurermps-6.11.0

    Check that you have the correct version of Azure PowerShell.