The Azure Cloud Shell uses Bash only and the documentation above is all about PowerShell. It took me a while to figure this out why it was not working. (I'm not an Azure dev).
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
@ArchieCoder thank you for bringing this to our attention. We will look into this issue and get back to you shortly. Thanks.
@rwallerms can you please update the document to refer to Azure PowerShell for each code snippet and update the "Try It" link for better user experience? Thanks.
For your information @ArchieCoder and @brandonh-msft, you can type pwsh in the command line and it'll switch to powershell mode. However, the document will be updated soon for clarity. Thanks.
Good deal. I filed this over on Cloud Shell's uservoice:

It's currently awaiting moderator approval but would also go a long way to solving this issue.
@brandonh-msft thank you very much for initiating this request. I agree with you, and I'll provide this feedback to our internal points of contact. Thanks.