|
1 | 1 | ---
|
2 | 2 | ms.service: azure-kubernetes-service
|
3 | 3 | ms.topic: include
|
4 |
| -ms.date: 02/21/2024 |
| 4 | +ms.date: 03/15/2024 |
5 | 5 | ---
|
6 | 6 |
|
7 |
| -> [!IMPORTANT] |
8 |
| -> Certain Azure security policies cause conflicts when used to sign in with `azd auth login`. As a workaround, you can perform a curl request to the localhost url you were redirected to after you logged in. |
| 7 | +### azd auth workaround |
9 | 8 |
|
10 |
| -The workaround requires the Azure CLI for authentication. If you don't have it or aren't using GitHub Codespaces, install the [Azure CLI][install-azure-cli]. |
| 9 | +This workaround requires you to have the [Azure CLI][install-azure-cli] installed. |
| 10 | + |
| 11 | +1. Open a terminal window and log in with the Azure CLI using the [`az login`][az-login] command with the `--scope` parameter set to `https://graph.microsoft.com/.default`. |
11 | 12 |
|
12 |
| -1. Inside a terminal, login with Azure CLI |
13 | 13 | ```azurecli-interactive
|
14 | 14 | az login --scope https://graph.microsoft.com/.default
|
15 | 15 | ```
|
16 |
| -1. Copy the "localhost" URL from the failed redirect |
17 |
| -1. In a new terminal window, type `curl` and paste your url |
18 |
| -1. If it works, code for a webpage saying "You have logged into Microsoft Azure!" appears |
19 |
| -
|
20 |
| -```html |
21 |
| -<!DOCTYPE html> |
22 |
| -<html> |
23 |
| -<head> |
24 |
| - <meta charset="utf-8" /> |
25 |
| - <meta http-equiv="refresh" content="60;url=https://docs.microsoft.com/cli/azure/"> |
26 |
| - <title>Login successfully</title> |
27 |
| - <style> |
28 |
| - body { |
29 |
| - font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; |
30 |
| - } |
31 |
| -
|
32 |
| - code { |
33 |
| - font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; |
34 |
| - display: inline-block; |
35 |
| - background-color: rgb(242, 242, 242); |
36 |
| - padding: 12px 16px; |
37 |
| - margin: 8px 0px; |
38 |
| - } |
39 |
| - </style> |
40 |
| -</head> |
41 |
| -<body> |
42 |
| - <h3>You have logged into Microsoft Azure!</h3> |
43 |
| - <p>You can close this window, or we will redirect you to the <a href="https://docs.microsoft.com/cli/azure/">Azure CLI documentation</a> in 1 minute.</p> |
44 |
| - <h3>Announcements</h3> |
45 |
| - <p>[Windows only] Azure CLI is collecting feedback on using the <a href="https://learn.microsoft.com/windows/uwp/security/web-account-manager">Web Account Manager</a> (WAM) broker for the login experience.</p> |
46 |
| - <p>You may opt-in to use WAM by running the following commands:</p> |
47 |
| - <code> |
48 |
| - az config set core.allow_broker=true<br> |
49 |
| - az account clear<br> |
50 |
| - az login |
51 |
| - </code> |
52 |
| -</body> |
53 |
| -</html> |
54 |
| -``` |
55 |
| - |
56 |
| -5. Close the new terminal and open the old terminal |
57 |
| -6. Copy and note down which subscription_id you want to use |
58 |
| -7. Paste in the subscription_ID to the command `az account set -n {sub}` |
59 |
| - |
60 |
| -[install-azure-cli]: /cli/azure/install-azure-cli |
| 16 | +
|
| 17 | + You should be redirected to an authentication page in a new tab to create a browser access token, as shown in the following example: |
| 18 | +
|
| 19 | + ```output |
| 20 | + https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize?clientid=<your_client_id>. |
| 21 | + ``` |
| 22 | +
|
| 23 | +2. Copy the localhost URL of the webpage you received after attempting to sign in with `azd auth login`. |
| 24 | +3. In a new terminal window, use the following `curl` request to log in. Make sure you replace the `<localhost>` placeholder with the localhost URL you copied in the previous step. |
| 25 | +
|
| 26 | + ```console |
| 27 | + curl <localhost> |
| 28 | + ``` |
| 29 | +
|
| 30 | + A successful login outputs an HTML webpage, as shown in the following example: |
| 31 | +
|
| 32 | + ```output |
| 33 | + <!DOCTYPE html> |
| 34 | + <html> |
| 35 | + <head> |
| 36 | + <meta charset="utf-8" /> |
| 37 | + <meta http-equiv="refresh" content="60;url=https://docs.microsoft.com/cli/azure/"> |
| 38 | + <title>Login successfully</title> |
| 39 | + <style> |
| 40 | + body { |
| 41 | + font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; |
| 42 | + } |
| 43 | + |
| 44 | + code { |
| 45 | + font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; |
| 46 | + display: inline-block; |
| 47 | + background-color: rgb(242, 242, 242); |
| 48 | + padding: 12px 16px; |
| 49 | + margin: 8px 0px; |
| 50 | + } |
| 51 | + </style> |
| 52 | + </head> |
| 53 | + <body> |
| 54 | + <h3>You have logged into Microsoft Azure!</h3> |
| 55 | + <p>You can close this window, or we will redirect you to the <a href="https://docs.microsoft.com/cli/azure/">Azure CLI documentation</a> in 1 minute.</p> |
| 56 | + <h3>Announcements</h3> |
| 57 | + <p>[Windows only] Azure CLI is collecting feedback on using the <a href="https://learn.microsoft.com/windows/uwp/security/web-account-manager">Web Account Manager</a> (WAM) broker for the login experience.</p> |
| 58 | + <p>You may opt-in to use WAM by running the following commands:</p> |
| 59 | + <code> |
| 60 | + az config set core.allow_broker=true<br> |
| 61 | + az account clear<br> |
| 62 | + az login |
| 63 | + </code> |
| 64 | + </body> |
| 65 | + </html> |
| 66 | + ``` |
| 67 | +
|
| 68 | +4. Close the current terminal and open the original terminal. You should see a JSON list of your subscriptions. |
| 69 | +5. Copy the `id` field of the subscription you want to use. |
| 70 | +6. Set your subscription using the [`az account set`][az-account-set] command. |
| 71 | +
|
| 72 | + ```azurecli-interactive |
| 73 | + az account set --subscription <subscription_id> |
| 74 | + ``` |
| 75 | +
|
| 76 | +<!-- LINKS - internal --> |
| 77 | +[install-azure-cli]: /cli/azure/install-azure-cli |
| 78 | +[az-login]: /cli/azure/#az-login |
| 79 | +[az-account-set]: /cli/azure/account#az-account-set |
0 commit comments