az mixin

This is a mixin for Porter that provides the Azure (az) CLI.

Source: https://github.com/deislabs/porter-az

Install or Upgrade

porter mixin install az

Mixin Configuration

When you declare the mixin, you can also configure additional extensions to install:

Use the vanilla az CLI

mixins:
- az

Install additional extensions

mixins:
- az:
    extensions:
    - EXTENSION_NAME

Mixin Syntax

See the az CLI Command Reference for the supported commands.

az:
  description: "Description of the command"
  arguments:
  - arg1
  - arg2
  flags:
    FLAGNAME: FLAGVALUE
    REPEATED_FLAG:
    - FLAGVALUE1
    - FLAGVALUE2
  outputs:
    - name: NAME
      jsonPath: JSONPATH
    - name: NAME
      path: SOURCE_FILEPATH

Outputs

The mixin supports jsonpath and path outputs.

JSON Path

The jsonPath output treats stdout like a json document and applies the expression, saving the result to the output.

outputs:
- name: NAME
  jsonPath: JSONPATH

For example, if the jsonPath expression was $[*].id and the command sent the following to stdout:

[
  {
    "id": "1085517466897181794",
    "name": "my-vm"
  }
]

Then then output would have the following contents:

["1085517466897181794"]

File Paths

The path output saves the content of the specified file path to an output.

outputs:
- name: kubeconfig
  path: /root/.kube/config

Examples

Install the Azure IoT Extension

mixins:
- az:
    extensions:
    - azure-cli-iot-ext

Authenticate

az:
  description: "Azure CLI login"
  arguments:
    - login
  flags:
    service-principal:
    username: "{{ bundle.credentials.AZURE_SP_CLIENT_ID}}"
    password: "{{ bundle.credentials.AZURE_SP_PASSWORD}}"
    tenant: "{{ bundle.credentials.AZURE_TENANT}}"

Provision a VM

az:
  description: "Create VM"
  arguments:
    - vm
    - create
  flags:
    resource-group: porterci
    name: myVM
    image: UbuntuLTS

Delete a VM

az:
  description: "Delete VM"
  arguments:
    - vm
    - delete
  flags:
    resource-group: porterci
    name: myVM