0
$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 ?

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

1 Comment

No problem. Glad to help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.