Reputation: 14586
$primaryEndpoints = az storage account show --resource-group rg --name sto --query 'primaryEndpoints'
The above command returns
{
"blob": "https://sto.blob.core.windows.net/",
"dfs": null,
"file": "https://sto.file.core.windows.net/",
"internetEndpoints": null,
"microsoftEndpoints": null,
"queue": "https://sto.queue.core.windows.net/",
"table": "https://sto.table.core.windows.net/",
"web": null
}
But his command below returns nothing :
echo $primaryEndpoints["blob"]
I've also tried
echo $primaryEndpoints.blob
How do I access the json property ?
Upvotes: 0
Views: 387
Reputation: 371
It seems to me that you are getting a JSON string as a return value. To access the properties by name, you need to first convert the JSON string to a PSObject.
$primaryEndpoints = az storage account show --resource-group rg --name sto --query 'primaryEndpoints'
$primaryEndpointObjects = $primaryEndpoints | ConvertFrom-Json
$primaryEndpointObjects.blob
Upvotes: 1