1

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?

0

2 Answers 2

4

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.

1
  • I have download in my AzureDevOps task 'Install-PackageProvider -Name NuGet -Force -Scope CurrentUser Get-Module -ListAvailable| where {$_.Name -Like '*AzureRM*'} | Select Name, Version Install-Module -Name AzureRM -RequiredVersion 6.11.0 -Force -Scope CurrentUser -AllowClobber Import-Module AzureRM -Force -Verbose -Scope Local Get-Module -ListAvailable| where {$_.Name -Like 'AzureRM'} | Select Name, Version' 6.11.0 but AzureRM.Search is not part of it.
    – Leszek
    Oct 27, 2018 at 18:30
1

To get the query key of the Azure Search service, @Victor Silva 's solution will work fine.

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

I have download in my AzureDevOps task 'xxxx' 6.11.0 but AzureRM.Search is not part of it

To your further issue, because the AzureRM.Search module is in the preview version, it is not be included in AzureRM 6.11.0 module, refer to the Package Details in this link. So if you want to use this command Get-AzureRmSearchQueryKey, you need to install the AzureRM.Search independently, use Install-Module -Name AzureRM.Search -AllowPrerelease, refer to this link.

Update:

If you want to list query keys via API, you could use this REST API.

GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/listQueryKeys?api-version=2015-08-19

enter image description here

5
  • I have failed to execute this in Windows PowerShell as well as in Azure DevOps Task. I can not verify this in AzureDevOps as the task throws 'WARNING: User declined to install module (AzureRM.Search)' while trying to install.
    – Leszek
    Oct 30, 2018 at 7:39
  • @Leszek Try to use -Force at the end, Install-Module -Name AzureRM.Search -AllowPrerelease -Force.
    – Joy Wang
    Oct 30, 2018 at 7:41
  • @Leszek Besides, if you want to use API, you could refer to my update.
    – Joy Wang
    Oct 30, 2018 at 8:22
  • I know API 'way' but thank you for pointing this out. I have tried with -Force.
    – Leszek
    Oct 30, 2018 at 22:17
  • As you have mentioned "To get the query key of the Azure Search service, @Victor Silva 's solution will work fine.". Yes, your answer is more complex, but I haven't succeeded to apply it.
    – Leszek
    Oct 31, 2018 at 7:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.