Azure / draft

A day 0 tool for getting your app on k8s fast
MIT License
506 stars 59 forks source link

draft setup-gh fails with error #102

Closed asw101 closed 2 years ago

asw101 commented 2 years ago

draft setup-gh fails with the following error:

$ draft setup-gh
✔ azure
Enter app registration name: ???
✔ ???
Enter resource group name: ???
Enter github organization and repo (organization/repoName): ???/???
[Draft] --> Setting up Github OIDC... ⡿ [Draft] ERROR: usage error: --assignee STRING | --assignee-object-id GUID

az version output:

$ az version
{
  "azure-cli": "2.33.1",
  "azure-cli-core": "2.33.1",
  "azure-cli-telemetry": "1.0.6",
  "extensions": {
    "containerapp": "0.3.4",
    "log-analytics": "0.2.2",
    "tipsextension": "0.0.1"
  }
}

I will submit a PR for this in a moment.

imiller31 commented 2 years ago

I just ran this on the main branch. Could you provide some more information about your environment, draft version, etc.

➜ draftv2 (main) ✗ ./draft setup-gh -p azure -v
Enter app registration name: iztesting
[Draft] Checking that Azure Cli is installed...
[Draft] Checking that user is logged in to Azure CLI...
✔ 0e0d6284-a155-4d10-83da-9675ef354298
Enter resource group name: izroll-dev
Enter github organization and repo (organization/repoName): imiller31/go_echo
[Draft] Commencing github connection with azure...
[Draft] Checking that github cli is installed...
[Draft] --> Setting up Github OIDC... ⣾ [Draft] Github cli found!
[Draft] Checking that user is logged in to github...
[Draft] --> Setting up Github OIDC... ⡿ [Draft] User is logged in!
[Draft] Checking that provided information is valid...
[Draft] --> Setting up Github OIDC... ⣾ [Draft] Commencing Azure app creation...
[Draft] 2022-06-14 11:39:06.760873 -0400 EDT m=+29.686785587
[Draft] --> Setting up Github OIDC... ⣷ [Draft] App created successfully!
[Draft] 5.506264772s
[Draft] Creating Azure service principal...
[Draft] 2022-06-14 11:39:12.26724 -0400 EDT m=+35.193102374
[Draft] --> Setting up Github OIDC... ⡿ [Draft] Checking sp was created...
[Draft] --> Setting up Github OIDC... ⣷ [Draft] Service principal exists
[Draft] Service principal created successfully!
[Draft] 3.987388489s
[Draft] Fetching Azure account tenant ID
[Draft] --> Setting up Github OIDC... ⣽ [Draft] Fetching Azure application object ID
[Draft] --> Setting up Github OIDC... ⣯ [Draft] Assigning contributor role to service principal...
[Draft] --> Setting up Github OIDC... ⣾ [Draft] Role assigned successfully!
[Draft] Checking for existing federated credentials...
[Draft] --> Setting up Github OIDC... ⣽ [Draft] No existing credentials found
[Draft] Creating federated credentials...
[Draft] --> Setting up Github OIDC... ⣾ [Draft] Waiting 10 seconds to allow credentials time to populate
[Draft] --> Setting up Github OIDC... ⢿ [Draft] Checking for existing federated credentials...
[Draft] --> Setting up Github OIDC... ⣽ [Draft] Credentials found
[Draft] Setting AZURE_CLIENT_ID in github...
[Draft] --> Setting up Github OIDC... ⢿ [Draft] Setting AZURE_SUBSCRIPTION_ID in github...
[Draft] --> Setting up Github OIDC... ⣷ [Draft] Setting AZURE_TENANT_ID in github...
[Draft] --> Setting up Github OIDC... ⢿ [Draft] Github connection with azure completed successfully!
[Draft] Draft has successfully set up Github OIDC for your project 😃
[Draft] Use 'draft generate-workflow' to generate a Github workflow to build and deploy an application on AKS.

az version

➜ draftv2 (main) ✗ az version
{
  "azure-cli": "2.37.0",
  "azure-cli-core": "2.37.0",
  "azure-cli-telemetry": "1.0.6",
  "extensions": {
    "aks-preview": "0.5.60"
  }
}
asw101 commented 2 years ago

I just re-ran from main and encountered a different error.

[Draft] --> Setting up Github OIDC... ⢿ Fatal: [69 82 82 79 82 58 32 84 104 101 32 100 105 114 101 99 116 111 114 121 32 111 98 106 101 99 116 32 113 117 111 116 97 32 108 105 109 105 116 32 102 111 114 32 116 104 101 32 80 114 105 110 99 105 112 97 108 32 104 97 115 32 98 101 101 110 32 101 120 99 101 101 100 101 100 46 32 80 108 101 97 115 101 32 97 115 107 32 121 111 117 114 32 97 100 109 105 110 105 115 116 114 97 116 111 114 32 116 111 32 105 110 99 114 101 97 115 101 32 116 104 101 32 113 117 111 116 97 32 108 105 109 105 116 32 111 114 32 100 101 108 101 116 101 32 111 98 106 101 99 116 115 32 116 111 32 114 101 100 117 99 101 32 116 104 101 32 117 115 101 100 32 113 117 111 116 97 46 10]
Exiting.

This is because az ad app create / createAppCmd := exec.Command("az", "ad", "app", "create", "--only-show-errors", "--display-name", sc.AppName) is failing in my directory, and it's using log.Fatal on a []byte.

I'll send a new PR to unblock this, avoid using log.Fatal, log.Printf the command output, and return errors instead.

For anyone hitting this, the underlying error is/was:

ERROR: The directory object quota limit for the Principal has been exceeded. Please ask your administrator to increase the quota limit or delete objects to reduce the used quota.

I'll then try to unblock the above and see if I can repro any further issues.

imiller31 commented 2 years ago

Thanks for catching this

asw101 commented 2 years ago

I recently noticed the original error may have been related to: https://docs.microsoft.com/en-ca/cli/azure/microsoft-graph-migration