You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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).
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:
23
23
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`.
26
29
27
-
> [!NOTE]
28
-
> This option works only in a non-interactive shell.
30
+
## Sign in with az devops login and enter your PAT
29
31
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:
az devops login --organization https://dev.azure.com/contoso
38
36
Token:
39
37
```
40
38
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`.
43
40
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.
45
42
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.
48
45
46
+
## Pipe a PAT to az devops login
49
47
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.
51
49
52
-
### From a variable
50
+
### Use a variable
53
51
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:
55
53
56
54
```azurecli
57
-
echo "######" | az devops login --organization https://dev.azure.com/contoso/
55
+
echo "######" | az devops login --organization https://dev.azure.com/contoso/
58
56
```
59
57
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:
61
61
62
62
```azurecli
63
63
cat my_pat_token.txt | az devops login --organization https://dev.azure.com/contoso/
64
64
```
65
65
66
-
## Use the AZURE_DEVOPS_EXT_PAT environment variable
66
+
## Authenticate with the AZURE_DEVOPS_EXT_PAT environment variable
67
67
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.
69
69
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.
0 commit comments