Skip to main content

A lemniscat plugin to run azurecli scripts

Project description

lemniscat.plugin.azurecli

A plugin to operate Azure services through Azure cli into a lemniscat workflow

Description

This plugin allows you to operate Azure services through Azure cli into a lemniscat manifest.

Usage

Pre-requisites

In order to use this plugin, you need to have an Azure subscription and an Azure service principal. You can create a service principal using the Azure CLI, PowerShell, or the Azure portal. The service principal is used to authenticate the Azure CLI to your Azure subscription.

After that you to be sure that you have the Azure CLI installed on your agent. You can install it using the following command:

Linux

curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash

Windows

Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'

You need also set environment variables to authenticate the Azure CLI to your Azure subscription.

  • ARM_SUBSCRIPTION_ID : The subscription ID that you want to use
  • ARM_CLIENT_ID : The client ID of the service principal
  • ARM_CLIENT_SECRET : The client secret of the service principal
  • ARM_TENANT_ID : The tenant ID of the service principal

You need to add plugin into the required section of your manifest file.

requirements:
  - name: lemniscat.plugin.azurecli
    version: 0.1.0.9

Running powershell commands with Azure CLI

- task: azurecli
  displayName: 'Azure CLI'
  steps:
    - run
  parameters:
    scripttype: pwsh
    commandtype: inline
    script: |
      $version = az --version
      Write-Host "Azure CLI version: $version"

Running powershell script with Azure CLI

- task: azurecli
  displayName: 'Azure CLI'
  steps:
    - run
  parameters:
    scripttype: pwsh
    commandtype: file
    filePath: ${{ workingdirectory }}/scripts/ClearAzureContainer.ps1
    fileParams:
      storageAccountName: ${{ storageAccountName }}
      containerName: ${{ containerName }}

Running powershell commmands and pass variables through json file

[!NOTE] This feature is particulary recommand when you need to manipulate complexe variable with your task. You can access to the variables in the json file by using the following command:

$location = Get-Location
$variables = Get-Content "$($location.path)/vars.json" | ConvertFrom-Json -Depth 100
- task: azurecli
  displayName: 'Azure CLI'
  steps:
    - run
  parameters:
    scripttype: pwsh
    commandtype: inline
    script: |
      $location = Get-Location
      $variables = Get-Content "$($location.path)/vars.json" | ConvertFrom-Json -Depth 100
      $version = az --version
      Write-Host "Azure CLI version: $version"
    storeVariablesInFile:
      format: json
      withSecrets: false

Inputs

Parameters

  • scripttype: The type of the script to run. It can be only pwsh (for the moment)
  • commandtype: The type of the command to run. It can be inline or file
  • script: The script to run. It can be a powershell command line. It is used only if commandtype is inline
  • filePath: The path of the powershell script file (*.ps1) to run. It is used only if commandtype is file
  • fileParams: The parameters to pass to the powershell script file. It is used only if commandtype is file
  • storeVariablesInFile: Describe the way to store the variables in a file to used in the task.

StoreVariablesInFile

  • format: The format of the file to store the variables. It can be json or yaml
  • withSecrets: A boolean value to indicate if the secrets should be stored in the file. It can be true or false

Outputs

You can push variables to the lemniscat runtime in order to be used after by other tasks. To do that, you need to use Write-Host command in your powershell script to push variables to the lemniscat runtime. You must use the following format to push variables to the lemniscat runtime: [lemniscat.pushvar] <variableName>=<variableValue>

For example:

Write-Host "[lemniscat.pushvar] workspaceExist=$workspaceExist"

You can specify the sensitivity of the variable by adding secret like this : [lemniscat.pushvar.secret] <variableName>=<variableValue>

For example:

Write-Host "[lemniscat.pushvar.secret] storageAccountKey=$storageAccountKey"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lemniscat_plugin_azurecli-0.2.5.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file lemniscat_plugin_azurecli-0.2.5.tar.gz.

File metadata

File hashes

Hashes for lemniscat_plugin_azurecli-0.2.5.tar.gz
Algorithm Hash digest
SHA256 b73bb456daa99bf023f36661b938ff5d53363242aeaac91e781a89b3e0e7e62e
MD5 46bad6783839cf68e06299abbb5b8953
BLAKE2b-256 c0b038c10d256f30ba3245b4e4808b64c6c174d70ac798a84edf1abdc35ad883

See more details on using hashes here.

File details

Details for the file lemniscat.plugin.azurecli-0.2.5-py3-none-any.whl.

File metadata

File hashes

Hashes for lemniscat.plugin.azurecli-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 af04404b94edc5df167cb808c6f9e22477f3281259f29728925c128b04f4455d
MD5 534b63b7f1f807b15892916846ef5b68
BLAKE2b-256 427137e920554ec738612778d5c00e5a6e096c5e5ba9ca02aefc517883ade27a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page