Skip to content

Commit 794694e

Browse files
authored
Merge pull request #8002 from MicrosoftDocs/users/chcomley/PATs-438641
[PATs/Entra] Added Entra verbiage, refreshed
2 parents 40b4801 + 4099abe commit 794694e

File tree

1 file changed

+27
-31
lines changed

1 file changed

+27
-31
lines changed

docs/cli/log-in-via-pat.md

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,68 +8,66 @@ ms.manager: mijacobs
88
ms.author: chcomley
99
author: chcomley
1010
monikerRange: 'azure-devops'
11-
ms.date: 01/08/2025
11+
ms.date: 06/05/2025
1212
---
1313

14-
# Sign in with a personal access token (PAT)
14+
# Sign in with a personal access token
1515

1616
[!INCLUDE [version-eq-azure-devops](../includes/version-eq-azure-devops.md)]
1717

18-
You can sign in using an Azure DevOps personal access token (PAT). To create a PAT, see [Use personal access tokens](../organizations/accounts/use-personal-access-tokens-to-authenticate.md#create-a-pat).
18+
This article explains how to sign in using an Azure DevOps personal access token (PAT). You can sign in [interactively with Microsoft Entra through the az login command](index.md) or by using an Azure DevOps PAT. To create a PAT, see [Use personal access tokens](../organizations/accounts/use-personal-access-tokens-to-authenticate.md#create-a-pat).
1919

2020
[!INCLUDE [use-microsoft-entra-reduce-pats](../includes/use-microsoft-entra-reduce-pats.md)]
2121

22-
To use a PAT with the Azure DevOps CLI, use one of these options:
22+
To use a PAT with the Azure DevOps CLI, choose one of these methods:
2323

24-
* Use `az devops login` and be [prompted for the PAT token](#user-prompted-to-use-az-devops-login).
25-
* Pipe the [PAT token on StdIn](#pipe-pat-on-stdin-to-az-devops-login) to `az devops login`.
24+
- Run `az devops login` and [enter the PAT token when prompted](#sign-in-with-a-personal-access-token).
25+
- Pipe the [PAT token to StdIn](#pipe-a-pat-to-az-devops-login) and use it with `az devops login`.
26+
> [!NOTE]
27+
> This method works only in a non-interactive shell.
28+
- Set the `AZURE_DEVOPS_EXT_PAT` [environment variable](#authenticate-with-the-azure_devops_ext_pat-environment-variable) and run CLI commands without using `az devops login`.
2629

27-
> [!NOTE]
28-
> This option works only in a non-interactive shell.
30+
## Sign in with az devops login and enter your PAT
2931

30-
* Set the `AZURE_DEVOPS_EXT_PAT` [environment variable]((#use-the-azuredevopsextpat-environment-variable), and don't use `az devops login`.
31-
32-
## User prompted to use az devops login
33-
34-
You're prompted to enter a PAT after you run the `az devops login` command:
32+
After you run the `az devops login` command, enter your personal access token (PAT) when prompted:
3533

3634
```azurecli
37-
$az devops login --organization https://dev.azure.com/contoso
35+
az devops login --organization https://dev.azure.com/contoso
3836
Token:
3937
```
4038

41-
> [!NOTE]
42-
> If you have already signed in with `az login` interactively or if you're using a user name and password, you're not required to provide a token because the `az devops` commands now support sign-in through `az login`.
39+
If you already signed in interactively with `az login` or used a user name and password, you don't need to provide a PAT. The `az devops` commands now support sign-in through `az login`.
4340

44-
When you're successfully signed in, this command also can set your default organization to Contoso, provided no default organization is configured.
41+
When you sign in successfully, this command can also set your default organization if none is configured.
4542

46-
> [!NOTE]
47-
> For Guest Users, only the `az devops login` is supported.
43+
> [!NOTE]
44+
> For Guest Users, only `az devops login` is supported.
4845
46+
## Pipe a PAT to az devops login
4947

50-
## Pipe PAT on StdIn to az devops login
48+
You can provide your PAT to the Azure DevOps CLI by piping it to the `az devops login` command. This approach is useful for automation and CI/CD pipelines where interactive input isn't possible.
5149

52-
### From a variable
50+
### Use a variable
5351

54-
This option is useful in pipelines in which you can replace `#####` with `$(System.AccessToken)` or another pipeline variable:
52+
Replace `######` with `$(System.AccessToken)` or another pipeline variable:
5553

5654
```azurecli
57-
echo "######" | az devops login --organization https://dev.azure.com/contoso/
55+
echo "######" | az devops login --organization https://dev.azure.com/contoso/
5856
```
5957

60-
### From a file
58+
### Use a file
59+
60+
You can also store your PAT in a file and pipe it to the login command:
6161

6262
```azurecli
6363
cat my_pat_token.txt | az devops login --organization https://dev.azure.com/contoso/
6464
```
6565

66-
## Use the AZURE_DEVOPS_EXT_PAT environment variable
66+
## Authenticate with the AZURE_DEVOPS_EXT_PAT environment variable
6767

68-
To gain access in a non-interactive manner for automation scenarios, you can use environment variables or fetch a PAT from a file.
68+
For non-interactive or automation scenarios, set the `AZURE_DEVOPS_EXT_PAT` environment variable to your PAT. If you haven't used `az login` or `az devops login`, all `az devops` commands attempt to use this variable for authentication.
6969

70-
If `az login` or `az devops login` haven't been used, all `az devops` commands try to sign in using a PAT stored in the `AZURE_DEVOPS_EXT_PAT` environment variable.
71-
72-
To use a PAT, set the `AZURE_DEVOPS_EXT_PAT` environment variable at the process level.
70+
Set the environment variable at the process level before running CLI commands to enable seamless authentication.
7371

7472
#### [Windows](#tab/windows)
7573

@@ -81,10 +79,8 @@ $env:AZURE_DEVOPS_EXT_PAT = 'xxxxxxxxxx'
8179

8280
##### [macOS and Linux](#tab/unix)
8381

84-
8582
```bash
8683
export AZURE_DEVOPS_EXT_PAT=xxxxxxxxxx
8784
```
8885

8986
Replace *xxxxxxxxxx* with your PAT.
90-

0 commit comments

Comments
 (0)