Skip to main content

Azure Cloud Shell Frequently asked questions

· 2 min read
  1. You don't need to install Azure CLI in your local dev environment.

    The Cloud Shell (Azure CLI in a browser) is available from the Azure portal.

    Screenshot showing Azure Cloud Shell is available from top navigation bar in Azure portal.

  2. The cloud shell is sticky. Because the Cloud shell uses Azure Storage (File storage), when you end your sessions then return, your files are still there.

    • Want to quickly work with a GitHub repo? No problem, git is available.
  3. Because you use it from the portal, you are already authenticated. No need for az login.

  4. Many CLI tools are already installed for you.

    • Azure CLI
    • git, zip, jq
    • code (not exactly Visual Studio Code, but a good IDE)
    • nano, vim
    • Node.js, npm
    • Java and Maven
    • Python
    • .NET Core
    • PowerShell
    • Go (Golang)
    • Azure Functions CLI
    • Docker CLI, Kubectl, Helm, Terraform, Ansible
    • Office 365 CLI
    • MySQL client
    • PostgreSql client
    • SQL cli
  5. Create bash scripts with Azure CLI commands to manage your Azure resources.

TypeScript type guard for empty JSON object

· One min read

A commit history for a repo on GitHub can be optional, if there are no commits yet. The TypeScript SDK created by the GraphQL CodeGen represents this optionality is represented with an empty object, null, or undefined. If a commit is present, its represented as a nested JSON object with more optional parameters.

declare var x:
{} |
null |
undefined |
{'a':
{ ... more optional params }
}

The empty JSON object, {}, is tricky in JavaScript. There are several examples of testing for an empty object but they generally don't work as type guards in TypeScript for type safety.

Type guard with in

After asking on StackOverlow and getting no response, I reached out to my local TypeScript expert for help.

He helped boil the issue down to the type shown in the previous code block with a type guard using the in keyword:

if (x !== null && x !== undefined && "a" in x) {
// no null
// not undefined
// x has property 'a' so it isn't empty
console.log(x.a);
}