Understanding Powershell extension for DevOps
In Azure devops, there is an extension called PowerShell for Mac, Windows and Linux. This is not the same as "Azure Powershell" which is targeted to run on window build host / agent.
Most of the time, I prefer to work with scripts based instead of inline scripts for tracking reasons.
Az cli extension will automatically login for you and you can start running various scripts. This extension, requires a manual login approach.
To installed a module, just do something like this
Install-Module -Name CosmosDB -Force
Some faq here
Can I used az cli based command here?
Yes you can. Can be as simple as follow :-
az login --service-principal --username $env:CLIENTID --password $env:CLIENTSECRET --tenant $env:TENANT_ID
az account set --subscription $env:SUBSCRIPTION
Or using powershell (you need to use "ConvertTo-SecureString". Pretty sure the following
Write-Host("init credential")
$passwd = ConvertTo-SecureString $env:CLIENTSECRET -AsPlainText -Force
$pscredential = New-Object System.Management.Automation.PSCredential($env:CLIENTID, $passwd)
Write-Host("Login into the system")
Connect-AzAccount -ServicePrincipal -Tenant $env:TENANT_ID -Credential $pscredential
Just make sure you setup your environment variables sections
Comments