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 useARM_CLIENT_ID
: The client ID of the service principalARM_CLIENT_SECRET
: The client secret of the service principalARM_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 onlypwsh
(for the moment)commandtype
: The type of the command to run. It can beinline
orfile
script
: The script to run. It can be a powershell command line. It is used only ifcommandtype
isinline
filePath
: The path of the powershell script file (*.ps1) to run. It is used only ifcommandtype
isfile
fileParams
: The parameters to pass to the powershell script file. It is used only ifcommandtype
isfile
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 bejson
oryaml
withSecrets
: A boolean value to indicate if the secrets should be stored in the file. It can betrue
orfalse
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
Built Distribution
File details
Details for the file lemniscat_plugin_azurecli-0.2.5.tar.gz
.
File metadata
- Download URL: lemniscat_plugin_azurecli-0.2.5.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b73bb456daa99bf023f36661b938ff5d53363242aeaac91e781a89b3e0e7e62e |
|
MD5 | 46bad6783839cf68e06299abbb5b8953 |
|
BLAKE2b-256 | c0b038c10d256f30ba3245b4e4808b64c6c174d70ac798a84edf1abdc35ad883 |
File details
Details for the file lemniscat.plugin.azurecli-0.2.5-py3-none-any.whl
.
File metadata
- Download URL: lemniscat.plugin.azurecli-0.2.5-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | af04404b94edc5df167cb808c6f9e22477f3281259f29728925c128b04f4455d |
|
MD5 | 534b63b7f1f807b15892916846ef5b68 |
|
BLAKE2b-256 | 427137e920554ec738612778d5c00e5a6e096c5e5ba9ca02aefc517883ade27a |