A quick an easy way to authenticate on Azure management API is to use az cli get-access-token command and use this as a Bearer token on your API calls.
Given that you have a blob storage container with multiple files, you could download the most latest one easily with az cli
In my scenario I have a container named backups which includes multiple MS SQL backups. I wanted to download the latest in order to restore through a pipeline on SQL server.
In order to accomplish that you should first login with az cli.
az login
If this is not possible through automation you would have to create a managed identity for your resource. The code is uploaded on the below gist.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When using powershell contains method you should be aware of the type of the object that is used.
Lets examine the below string which was used with contains on a powershell script.
Processed 384 pages for database ‘restore’, file ‘restore’ on file 1. Processed 2 pages for database ‘restore’, file ‘restore_log’ on file 1. RESTORE DATABASE successfully processed 386 pages in 0.004 seconds (752.929 MB/sec).
The string was stored on $result variable and I wanted to capture if a specific string was included in the variable. Although the string is included in the variable the result was false.
After investigating I was able to figure that the object type of the $result variable was an object and Contains could not evaluate successfully
In this situation you would have to cast the object on a string data type to evaluate correctly.
For example when using Get-Content you could cast to a string like below.
Following my previous article about how to update a variable group using POSTMAN, I will now document how to implement the same behavior through a pipeline.
First things first you will need a PAT. I have included this PAT in a different variable group than the one that I will update. this is because when you update the variable group, all the variables that are inside will get lost. If you need to retain them, you should have to get them first and then add them again on the variable group.
For this reason I have created a variable group named token-group which holds my PAT. I also made this variable a secret.
The variable group that I will update has the name of var-group and the id of 5.
The pipeline includes two tasks. The first task will loop through the variables on the group and print them out. The second task will update the variable group based on the JSON that you provided. You should change your ORG and project URLs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
After running the pipeline you will notice a null output on the update of the variable group. This is the requested result and as task has not failed your var group will get updated.
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here:
Cookie Policy