How to get the key of all the Azure Services in same way through powershell

Clash Royale CLAN TAG#URR8PPPHow to get the key of all the Azure Services in same way through powershell
I am trying to develop a PowerShell script for getting the key using Invoke-AzureRmResourceAction command of different Azure services, like below
Invoke-AzureRmResourceAction
$keyValue=Invoke-AzureRmResourceAction -Action listKeys -ResourceId $ResourceId -force
The problem is, I am getting the key to different services in a different way. Like for storage account, I have to write $keyValue.keys[0].value for getting the 1st key value. But for cognitive service, I have to write $keyValue.key1. Is there any way to generalized it so that same thing works for all the services in Azure which has the s key.
$keyValue.keys[0].value
$keyValue.key1
1 Answer
1
I think you could not access it via the same command. Different azure services have different resource structures, so the result format of the command will be different.
I recommend you to add logic to judge different services in your commands and run different command for them.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.