Posts

Showing posts with the label Powershell

List of Repositories - Authorize Rest API calls using Job Access Token

Image
  Author: Akhil M Anil || DevOps Engineer Getting the complete list of Repository names  in Azure DevOps Project using REST Api and Publishing as a CSV file. In the last blog I have talked about Authorizing REST API call using Job Access Tokens. If missed, please find that blog here:  Job Access Tokens . In this blog we will use Job Access Token to Authorize Rest API call and retrieve the list of repositories.  Full code can be found in GitHub:  Repository-List Steps: Push the developed pipeline code  (azure-pipelines-repos.yml) and python code  (repos.py) to Azure Repos. We are using  Repositories - List - REST API  to fetch the repository list using python. Job Authorization Scope for Job Access token. In order to access repositories using system access token, we need to change our default job authorization scope. In my last blog I have already mentioned about Job Authorization Scopes, feel free to take a look.  To set job a...

Job Access Tokens || Authorize REST API calls to access resources in ADO using Job Access Tokens

Image
  Author: Akhil M Anil || DevOps Engineer For applications that interface with Azure DevOps Services, you must authenticate to gain access to resources like REST APIs. There are different ways to authenticate our applications with Azure DevOps Services. In this article we will use job access token/system access token (SYS_TOKEN) to authenticate into Azure DevOps. A job access token is a security token that is dynamically generated by Azure Pipelines for each job at run time. The agent on which the job is running uses the job access token in order to access these resources in Azure DevOps. It is fully possible to use System Access Tokens and eliminate the need for PATs in ADO pipeline for authorize the REST API calls to ADO. Furthermore, there is no need to save any credentials to files on disc and the System Access Tokens can be leveraged transiently as environment variables scoped to a specific job. The token's permissions are derived from job authorization scope the permis...

Authenticate to Azure DevOps using PAT token

Image
  Author: Akhil M Anil || DevOps Engineer For applications that interface with Azure DevOps Services, you must authenticate to gain access to resources like REST APIs. There are different ways to authenticate our applications with Azure DevOps Services. In this article we will use a personal access token (PAT) to authenticate into Azure DevOps. A personal access token contains your security credentials for Azure DevOps. A PAT identifies you, your accessible organizations, and scopes of access. As such, they're as critical as passwords. Since PAT is as identical as a user credential many organizations restrict its usage in Azure DevOps Api's instead promote the usage of any other authentication method or store the PAT token in Key-Vaults and use them. 1. Let's create a PAT token in ADO.  Sign into your organization From the home screen select the user settings and select Personal Access Token. Select +New Token. Give a name for the token, select the organization then set...

Pull Request Validation pipeline for branch policy in Azure DevOps

Image
Author: Akhil M Anil || DevOps Engineer A "PR" pipeline is just a pipeline that is triggered when a user creates a new pull request. It can be used for running tests, static analysis, linting, or other checks against the incoming branch as a way to ensure coding standards are met before merging the PR. Here we will see how we can impose branch policy in the PR validation pipeline and restrict the merging of codes to higher branches directly from lower branches. Consider we have 4 main branches Master/main, SIT, Integration, and dev. If we have an approved branching strategy that restricts the merging of the codes to any other branches than the specified branches, for example, the codes from dev can only be merged to the Integration branch, and the testing and deploying to the test environment will happen from the Integration branch, and similarly, after successful testing in a test environment the codes can be merged to SIT branch and testing and deployment in a UAT enviro...

Install Java silently using powershell in Azure Windows VM

Image
Written by Akhil M Anil . To install Java silently using PowerShell in Windows VM, follow the following steps: Downloading Java can be done in two ways:   Download your required Java version ( Java Downloads | Oracle ) to a folder in your Windows VM.     Use PowerShell to Download Java to a folder.  Follow the below steps for downloading Java through PowerShell : Initially copy the Download link for your required Java version, Java file name, and Location where you want to download Java in your VM to a notepad Open PowerShell  Run the following command in PowerShell $url = "<your-copied url>" $filename = "<file_name>" $dest = "<outputfile-location\$filename>" Invoke-WebRequest -Uri $url -OutFile $dest For Example:  $url = "https://download.oracle.com/java/18/latest/jdk-18_windows-x64_bin.exe" $filename = "jdk-18_windows-x64_bin.exe"  $dest = "C:\Users\akhilanil\Desktop\Java\$filename" Invoke-WebRequest -Uri ...