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

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


How 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.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Visual Studio Code: How to configure includePath for better IntelliSense results

C++ virtual function: Base class function is called instead of derived