Azure / azure-dev

A developer CLI that reduces the time it takes for you to get started on Azure. The Azure Developer CLI (azd) provides a set of developer-friendly commands that map to key stages in your workflow - code, build, deploy, monitor, repeat.
https://aka.ms/azd
MIT License
406 stars 196 forks source link

[Issue] azd pipeline config for azdo fails "ERROR: ensuring git remote: Looking for repository: The resource cannot be found." #3037

Closed jasontaylordev closed 7 months ago

jasontaylordev commented 10 months ago

Output from azd version azd version 1.5.0 (commit 012ae734904e0c376ce5074605a6d0d3f05789ee)

Describe the bug The command:

azd pipeline config --provider azdo --principal-name sp-EntraAssessDev --debug

Results in the error:

ERROR: ensuring git remote: Looking for repository: The resource cannot be found.

To Reproduce Outside of my environment, not sure.

Expected behavior The pipeline is configured or a detailed error message is returned.

Environment Information on your environment:

Additional context

I can commit and push changes from the command line. So I'm not sure why it can't find the repository. Any help is appreciated. 😀

DebugOutput.txt

jasontaylordev commented 10 months ago

Also, I'm not sure if I am recalling this correctly or not but isn't there some instructions on manually configuring an AZDO pipeline for AZD somewhere?

vhvb1989 commented 10 months ago

Also, I'm not sure if I am recalling this correctly or not but isn't there some instructions on manually configuring an AZDO pipeline for AZD somewhere?

This might be useful: https://github.com/Azure/azure-dev/blob/main/cli/azd/docs/manual-pipeline-config.md

vhvb1989 commented 10 months ago

@jasontaylordev , what do you get if you run git remote -v ?

IIRC, if the remote is using ssh, azd won't work for azdo... there was a pending issue to fix. https should be fine

jasontaylordev commented 10 months ago

@jasontaylordev , what do you get if you run git remote -v ?

~#@❯ git remote -v origin https://Increment-Works@dev.azure.com/Increment-Works/EntraAssess/_git/EntraAssess (fetch) origin https://Increment-Works@dev.azure.com/Increment-Works/EntraAssess/_git/EntraAssess (push)

Thanks for looking into this @vhvb1989 😀

jasontaylordev commented 10 months ago

I have now manually configured the pipeline and it is working well. I did not identify the root cause, but can still reproduce the error locally by running azd pipeline config --provider azdo --principal-name sp-EntraAssessDev --debug.

I'm happy to keep troubleshooting this issue; let me know what you would like to try next.

If not, feel free to close as I am no longer blocked.

mip1983 commented 8 months ago

Also having this issue

rajeshkamal5050 commented 7 months ago

@jasontaylordev , what do you get if you run git remote -v ?

IIRC, if the remote is using ssh, azd won't work for azdo... there was a pending issue to fix. https should be fine

Feature is tracked via #1896 closing this as a duplicate.

pbusfield commented 2 months ago

@rajeshkamal5050 This issue still exists under https ?

After Running : azd pipeline config -e dev

  (✓) Done: Checking current directory for Git repository

ERROR: ensuring git remote: Looking for repository: The resource cannot be found.
PS C:\FOLDER\> git remote -v     
origin  https://ORG@dev.azure.com/ORG/REPO/_git/REPO (fetch)
origin  https://ORG@dev.azure.com/ORG/REPO/_git/REPO (push)
PS C:\FOLDER\> 

azd version 1.9.5

vhvb1989 commented 2 months ago

@pbusfield , we have an open PR which should fix this. See: https://github.com/Azure/azure-dev/pull/4104

Can you try installing azd from that PR to validate your use case?

pbusfield commented 2 months ago

@vhvb1989 @rajeshkamal5050 No, this version didn't fix my issue, I still got the same error.

PS C:\FOLDER\APPNAME> azd pipeline config --provider azdo -e test

Configure your Azure DevOps pipeline

You need an Azure DevOps Personal Access Token (PAT). Create a PAT by following the instructions here https://aka.ms/azure-dev/azdo-pat
(skip this prompt by setting the PAT to env var: AZURE_DEVOPS_EXT_PAT)
? Personal Access Token (PAT): ****************************************************
  (✓) Done: Checking current directory for Git repository

ERROR: ensuring git remote: Looking for repository: The resource cannot be found.

I confirm the .git folder is in the C:\FOLDER\APPNAME location.

vhvb1989 commented 2 months ago

@pbusfield , can you run the command with debug, like azd pipeline config --debug and share the logs?

The error there is coming after trying to fetch the git remote repository from the Azdo Org/project and it is not found. We need to check the http response from the debug to see if it is unauthorized (your PAT has no access to read repos) or if it is a 404 (the git repo does not exists)

pbusfield commented 2 months ago

@vhvb1989 I gave the PAT full access to make sure this wasn't the issue.

These are the logs:

PS C:\ORG\REPO> azd pipeline config --debug 2024/08/02 10:09:20 main.go:56: azd version: 1.10.0-beta.1-pr.3987584 (commit 29a1b6244357a139e52c47f6dfbde67e6afb8b2b) 2024/08/02 10:09:20 main.go:217: ignoring cached latest version, it is out of date 2024/08/02 10:09:20 main.go:239: fetching latest version information for update check 2024/08/02 10:09:20 project.go:120: Reading project from file 'C:\ORG\REPO\azure.yaml' 2024/08/02 10:09:20 middleware.go:108: running middleware 'debug' 2024/08/02 10:09:20 middleware.go:108: running middleware 'ux' 2024/08/02 10:09:20 middleware.go:108: running middleware 'experimentation' 2024/08/02 10:09:20 assignment.go:87: could not read assignment from cache: cache expired 2024/08/02 10:09:20 main.go:50: Retry: =====> Try=1 2024/08/02 10:09:20 main.go:50: Request: ==> OUTGOING REQUEST (Try=1) GET https://default.exp-tas.com/exptas49/b80dfe81-554e-48ec-a7bc-1dd773cd6a54-azdexpws/api/v1/tas Accept: application/json User-Agent: azsdk-go-variantassignment/0.0.1 (go1.21.0 X:loopvar; Windows_NT) X-ExP-Parameters: REDACTED X-Exp-Sdk-Version: REDACTED

2024/08/02 10:09:20 main.go:50: Response: ==> REQUEST/RESPONSE (Try=1/270.4291ms, OpTime=271.6239ms) -- RESPONSE RECEIVED GET https://default.exp-tas.com/exptas49/b80dfe81-554e-48ec-a7bc-1dd773cd6a54-azdexpws/api/v1/tas Accept: application/json User-Agent: azsdk-go-variantassignment/0.0.1 (go1.21.0 X:loopvar; Windows_NT) X-ExP-Parameters: REDACTED X-Exp-Sdk-Version: REDACTED

RESPONSE Status: 200 OK Content-Length: 233 Content-Type: application/json; charset=utf-8 Date: Fri, 02 Aug 2024 00:09:19 GMT Etag: 941858517_1546953650 X-Cache: REDACTED X-Content-Type-Options: REDACTED X-Exp-Trackingid: REDACTED X-Msedge-Ref: REDACTED

2024/08/02 10:09:20 main.go:50: Retry: response 200 2024/08/02 10:09:20 main.go:50: Retry: exit due to non-retriable status code 2024/08/02 10:09:20 experimentation.go:42: assignment context: 0g5ad841:76970; 2024/08/02 10:09:20 middleware.go:108: running middleware 'telemetry' 2024/08/02 10:09:20 telemetry.go:43: TraceID: 64639cc31033b20fbae78e1c7682b753 2024/08/02 10:09:20 project.go:120: Reading project from file 'C:\ORG\REPO\azure.yaml' 2024/08/02 10:09:21 command_runner.go:307: Run exec: 'git -C C:\ORG\REPO rev-parse --show-toplevel' , exit code: 0 -------------------------------------stdout------------------------------------------- C:/ORG/REPO 2024/08/02 10:09:21 pipeline_manager.go:659: Loading project configuration from: C:\ORG\REPO\azure.yaml 2024/08/02 10:09:21 project.go:120: Reading project from file 'C:\ORG\REPO\azure.yaml' 2024/08/02 10:09:21 pipeline_manager.go:664: Loaded project configuration: &{RequiredVersions: Name:REPO ResourceGroupName:{template:} Path:C:\ORG\REPO Metadata: Services:map[app:0xc0004b8240] Infra:{Provider: Path:infra Module: IgnoreDeploymentState:false} Pipeline:{Provider: Variables:[] Secrets:[]} Hooks:map[] State: Platform: Workflows:map[] Cloud: EventDispatcher:0xc00061a230}
2024/08/02 10:09:21 pipeline_manager.go:674: Using persisted provider from environment: azdo 2024/08/02 10:09:21 project.go:120: Reading project from file 'C:\ORG\REPO\azure.yaml' 2024/08/02 10:09:21 importer.go:127: using infrastructure from C:\ORG\REPO\infra directory 2024/08/02 10:09:21 pipeline_manager.go:791: Checking for provider files for: azdo 2024/08/02 10:09:21 pipeline_manager.go:820: YAML path: C:\ORG\REPO.azdo\pipelines\azure-dev.yml 2024/08/02 10:09:21 pipeline_manager.go:821: Directory path: C:\ORG\REPO.azdo\pipelines 2024/08/02 10:09:21 pipeline_manager.go:832: Checking if directory C:\ORG\REPO.azdo\pipelines is empty 2024/08/02 10:09:21 pipeline_manager.go:857: Provider files are present for: azdo 2024/08/02 10:09:21 pipeline_manager.go:747: Using pipeline provider: Azure DevOps 2024/08/02 10:09:21 importer.go:127: using infrastructure from C:\ORG\REPO\infra directory 2024/08/02 10:09:21 command_runner.go:307: Run exec: 'C:\Users\MYNAME.azd\bin\bicep.exe --version' , exit code: 0 -------------------------------------stdout------------------------------------------- Bicep CLI version 0.28.1 (ba1e9f8c1e) 2024/08/02 10:09:21 bicep.go:97: bicep version: 0.28.1 2024/08/02 10:09:21 bicep.go:111: using local bicep: C:\Users\MYNAME.azd\bin\bicep.exe |= | Initialize bicep provider2024/08/02 10:09:22 main.go:296: updated cache file to version 1.9.5 (expires on: 2024-08-03T00:09:22Z) | | Initialize bicep provider2024/08/02 10:09:24 command_runner.go:307: Run exec: 'C:\Users\MYNAME.azd\bin\bicep.exe build C:\ORG\REPO\infra\main.bicep --stdout' , exit code: 0 -------------------------------------stdout------------------------------------------- { "$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#", "contentVersion": "1.0.0.0", "metadata": { "_generator": { "name": "bicep", "version": "0.28.1.47646", "templateHash": "373355230523436896" } }, "parameters": { "environmentName": { "type": "string", "minLength": 1, "maxLength": 64, "metadata": { "description": "Name of the environment that can be used as part of naming resource convention, the name of the resource group for your application will use this name, prefixed with rg-" } }, "location": { "type": "string", "minLength": 1, "metadata": { "description": "The location used for all deployed resources" } }, "principalId": { "type": "string", "defaultValue": "", "metadata": { "description": "Id of the user or app to assign application roles" } } }, "variables": { "tags": { "azd-env-name": "[parameters('environmentName')]" } }, "resources": [ { "type": "Microsoft.Resources/resourceGroups", "apiVersion": "2022-09-01", "name": "[format('rg-{0}', parameters('environmentName'))]", "location": "[parameters('location')]", "tags": "[variables('tags')]" }, { "type": "Microsoft.Resources/deployments", "apiVersion": "2022-09-01", "name": "resources", "resourceGroup": "[format('rg-{0}', parameters('environmentName'))]", "properties": { "expressionEvaluationOptions": { "scope": "inner" }, "mode": "Incremental", "parameters": { "location": { "value": "[parameters('location')]" }, "tags": { "value": "[variables('tags')]" }, "principalId": { "value": "[parameters('principalId')]" } }, "template": { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "metadata": { "_generator": { "name": "bicep", "version": "0.28.1.47646", "templateHash": "11585549932300993993" } }, "parameters": { "location": { "type": "string", "defaultValue": "[resourceGroup().location]", "metadata": { "description": "The location used for all deployed resources" } }, "principalId": { "type": "string", "defaultValue": "", "metadata": { "description": "Id of the user or app to assign application roles" } }, "tags": { "type": "object", "defaultValue": {}, "metadata": { "description": "Tags that will be applied to all resources" } } }, "variables": { "resourceToken": "[uniqueString(resourceGroup().id)]" }, "resources": [ { "type": "Microsoft.App/managedEnvironments/dotNetComponents", "apiVersion": "2024-02-02-preview", "name": "[format('{0}/{1}', format('cae-{0}', variables('resourceToken')), 'aspire-dashboard')]", "properties": { "componentType": "AspireDashboard" }, "dependsOn": [ "[resourceId('Microsoft.App/managedEnvironments', format('cae-{0}', variables('resourceToken')))]" ] }, { "type": "Microsoft.ManagedIdentity/userAssignedIdentities", "apiVersion": "2023-01-31", "name": "[format('mi-{0}', variables('resourceToken'))]", "location": "[parameters('location')]", "tags": "[parameters('tags')]" }, { "type": "Microsoft.ContainerRegistry/registries", "apiVersion": "2023-07-01", "name": "[replace(format('acr-{0}', variables('resourceToken')), '-', '')]", "location": "[parameters('location')]", "sku": { "name": "Basic" }, "properties": { "adminUserEnabled": true }, "tags": "[parameters('tags')]" }, { "type": "Microsoft.Authorization/roleAssignments", "apiVersion": "2022-04-01", "scope": "[format('Microsoft.ContainerRegistry/registries/{0}', replace(format('acr-{0}', variables('resourceToken')), '-', ''))]", "name": "[guid(resourceId('Microsoft.ContainerRegistry/registries', replace(format('acr-{0}', variables('resourceToken')), '-', '')), resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', format('mi-{0}', variables('resourceToken'))), subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '7f951dda-4ed3-4680-a7ca-43fe172d538d'))]", "properties": { "principalId": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', format('mi-{0}', variables('resourceToken'))), '2023-01-31').principalId]", "principalType": "ServicePrincipal", "roleDefinitionId": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '7f951dda-4ed3-4680-a7ca-43fe172d538d')]" }, "dependsOn": [ "[resourceId('Microsoft.ContainerRegistry/registries', replace(format('acr-{0}', variables('resourceToken')), '-', ''))]", "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', format('mi-{0}', variables('resourceToken')))]" ] }, { "type": "Microsoft.OperationalInsights/workspaces", "apiVersion": "2022-10-01", "name": "[format('law-{0}', variables('resourceToken'))]", "location": "[parameters('location')]", "properties": { "sku": { "name": "PerGB2018" } }, "tags": "[parameters('tags')]" }, { "type": "Microsoft.App/managedEnvironments", "apiVersion": "2024-02-02-preview", "name": "[format('cae-{0}', variables('resourceToken'))]", "location": "[parameters('location')]", "properties": { "workloadProfiles": [ { "workloadProfileType": "Consumption", "name": "consumption" } ], "appLogsConfiguration": { "destination": "log-analytics", "logAnalyticsConfiguration": { "customerId": "[reference(resourceId('Microsoft.OperationalInsights/workspaces', format('law-{0}', variables('resourceToken'))), '2022-10-01').customerId]", "sharedKey": "[listKeys(resourceId('Microsoft.OperationalInsights/workspaces', format('law-{0}', variables('resourceToken'))), '2022-10-01').primarySharedKey]" } } }, "tags": "[parameters('tags')]", "dependsOn": [ "[resourceId('Microsoft.OperationalInsights/workspaces', format('law-{0}', variables('resourceToken')))]" ] }, { "type": "Microsoft.Authorization/roleAssignments", "apiVersion": "2022-04-01", "scope": "[format('Microsoft.App/managedEnvironments/{0}', format('cae-{0}', variables('resourceToken')))]", "name": "[guid(resourceId('Microsoft.App/managedEnvironments', format('cae-{0}', variables('resourceToken'))), parameters('principalId'), subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c'))]", "properties": { "principalId": "[parameters('principalId')]", "roleDefinitionId": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c')]" }, "dependsOn": [ "[resourceId('Microsoft.App/managedEnvironments', format('cae-{0}', variables('resourceToken')))]" ] } ], "outputs": { "MANAGED_IDENTITY_CLIENT_ID": { "type": "string", "value": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', format('mi-{0}', variables('resourceToken'))), '2023-01-31').clientId]" }, "MANAGED_IDENTITY_NAME": { "type": "string", "value": "[format('mi-{0}', variables('resourceToken'))]" }, "MANAGED_IDENTITY_PRINCIPAL_ID": { "type": "string", "value": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', format('mi-{0}', variables('resourceToken'))), '2023-01-31').principalId]" }, "AZURE_LOG_ANALYTICS_WORKSPACE_NAME": { "type": "string", "value": "[format('law-{0}', variables('resourceToken'))]" }, "AZURE_LOG_ANALYTICS_WORKSPACE_ID": { "type": "string", "value": "[resourceId('Microsoft.OperationalInsights/workspaces', format('law-{0}', variables('resourceToken')))]" }, "AZURE_CONTAINER_REGISTRY_ENDPOINT": { "type": "string", "value": "[reference(resourceId('Microsoft.ContainerRegistry/registries', replace(format('acr-{0}', variables('resourceToken')), '-', '')), '2023-07-01').loginServer]" }, "AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID": { "type": "string", "value": "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', format('mi-{0}', variables('resourceToken')))]" }, "AZURE_CONTAINER_APPS_ENVIRONMENT_NAME": { "type": "string", "value": "[format('cae-{0}', variables('resourceToken'))]" }, "AZURE_CONTAINER_APPS_ENVIRONMENT_ID": { "type": "string", "value": "[resourceId('Microsoft.App/managedEnvironments', format('cae-{0}', variables('resourceToken')))]" }, "AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN": { "type": "string", "value": "[reference(resourceId('Microsoft.App/managedEnvironments', format('cae-{0}', variables('resourceToken'))), '2024-02-02-preview').defaultDomain]" } } } }, "dependsOn": [ "[subscriptionResourceId('Microsoft.Resources/resourceGroups', format('rg-{0}', parameters('environmentName')))]" ] } ], "outputs": { "MANAGED_IDENTITY_CLIENT_ID": { "type": "string", "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, format('rg-{0}', parameters('environmentName'))), 'Microsoft.Resources/deployments', 'resources'), '2022-09-01').outputs.MANAGED_IDENTITY_CLIENT_ID.value]" }, "MANAGED_IDENTITY_NAME": { "type": "string", "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, format('rg-{0}', parameters('environmentName'))), 'Microsoft.Resources/deployments', 'resources'), '2022-09-01').outputs.MANAGED_IDENTITY_NAME.value]" }, "AZURE_LOG_ANALYTICS_WORKSPACE_NAME": { "type": "string", "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, format('rg-{0}', parameters('environmentName'))), 'Microsoft.Resources/deployments', 'resources'), '2022-09-01').outputs.AZURE_LOG_ANALYTICS_WORKSPACE_NAME.value]" }, "AZURE_CONTAINER_REGISTRY_ENDPOINT": { "type": "string", "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, format('rg-{0}', parameters('environmentName'))), 'Microsoft.Resources/deployments', 'resources'), '2022-09-01').outputs.AZURE_CONTAINER_REGISTRY_ENDPOINT.value]" }, "AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID": { "type": "string", "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, format('rg-{0}', parameters('environmentName'))), 'Microsoft.Resources/deployments', 'resources'), '2022-09-01').outputs.AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID.value]" }, "AZURE_CONTAINER_APPS_ENVIRONMENT_NAME": { "type": "string", "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, format('rg-{0}', parameters('environmentName'))), 'Microsoft.Resources/deployments', 'resources'), '2022-09-01').outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_NAME.value]" }, "AZURE_CONTAINER_APPS_ENVIRONMENT_ID": { "type": "string", "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, format('rg-{0}', parameters('environmentName'))), 'Microsoft.Resources/deployments', 'resources'), '2022-09-01').outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID.value]" }, "AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN": { "type": "string", "value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, format('rg-{0}', parameters('environmentName'))), 'Microsoft.Resources/deployments', 'resources'), '2022-09-01').outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN.value]" } } } -------------------------------------stderr------------------------------------------- C:\ORG\REPO\infra\resources.bicep(51,34) : Warning BCP081: Resource type "Microsoft.App/managedEnvironments@2024-02-02-preview" does not have types available. Bicep is unable to validate resource properties prior to deployment, but this will not block the resource from being deployed. C:\ORG\REPO\infra\resources.bicep(69,28) : Warning BCP081: Resource type "Microsoft.App/managedEnvironments/dotNetComponents@2024-02-02-preview" does not have types available. Bicep is unable to validate resource properties prior to deployment, but this will not block the resource from being deployed. |== | Initialize bicep provider2024/08/02 10:09:25 main.go:50: Retry: =====> Try=1 |=== | Initialize bicep provider2024/08/02 10:09:25 main.go:50: Request: ==> OUTGOING REQUEST (Try=1) GET https://graph.microsoft.com/v1.0/me Authorization: REDACTED Client-Request-Id: REDACTED User-Agent: azsdk-go-graph/1.0.0 (go1.21.0 X:loopvar; Windows_NT),azdev/1.10.0-beta.1-pr.3987584 (Go go1.21.0 X:loopvar; windows/amd64)

|==== | Initialize bicep provider2024/08/02 10:09:25 main.go:50: Response: ==> REQUEST/RESPONSE (Try=1/363.9955ms, OpTime=365.6135ms) -- RESPONSE RECEIVED GET https://graph.microsoft.com/v1.0/me Authorization: REDACTED Client-Request-Id: REDACTED User-Agent: azsdk-go-graph/1.0.0 (go1.21.0 X:loopvar; Windows_NT),azdev/1.10.0-beta.1-pr.3987584 (Go go1.21.0 X:loopvar; windows/amd64)

RESPONSE Status: 200 OK Cache-Control: no-cache Client-Request-Id: REDACTED Content-Type: application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8 Date: Fri, 02 Aug 2024 00:09:25 GMT Odata-Version: REDACTED Request-Id: 75d1218e-9f38-4518-b3e2-c4a32541bcce Strict-Transport-Security: REDACTED Vary: REDACTED X-Ms-Ags-Diagnostic: REDACTED X-Ms-Resource-Unit: REDACTED

2024/08/02 10:09:25 main.go:50: Retry: response 200 2024/08/02 10:09:25 main.go:50: Retry: exit due to non-retriable status code

Configure your Azure DevOps pipeline

You need an Azure DevOps Personal Access Token (PAT). Create a PAT by following the instructions here https://aka.ms/azure-dev/azdo-pat (skip this prompt by setting the PAT to env var: AZURE_DEVOPS_EXT_PAT) ? Personal Access Token (PAT): ****

| | Checking current directory for Git repository2024/08/02 10:10:07 command_runner.go:307: Run exec: 'git -C C:\ORG\REPO remote get-url origin' , exit code: 0 -------------------------------------stdout------------------------------------------- https://ORG@dev.azure.com/ORG/REPO/_git/REPO |= | Checking current directory for Git repository2024/08/02 10:10:07 command_runner.go:307: Run exec: 'git -C C:\ORG\REPO branch --show-current' , exit code: 0 -------------------------------------stdout------------------------------------------- az-pipelines (✓) Done: Checking current directory for Git repository

ERROR: ensuring git remote: Looking for repository: The resource cannot be found.

vhvb1989 commented 2 months ago

thank you @pbusfield . Can you tell the steps you followed to clone or get your project? Did you start from a local folder (w/o a git remote) or did you clone the project from some existing repo with either azd init -t ... or git clone ... ?

The error you are getting is b/c azd is not finding the git repo in the Azdo Org/Project. But the remote is already set in your project (like if you previously clone the project from the Org/Project git repo or something).

This can happen, for example, if you:

You can, for example, remove the git remote from your project by running git remote remove origin , then if you run azd pipeline config, azd will not try to fetch an existing remote. Instead, azd will ask you if you want to create a new repository or pick an existing one. If you select pick one, azd will list all the repositories from the project and let you choose from there.

Hope this can help to figure what's happening with your project config

pbusfield commented 2 months ago

@vhvb1989 Thanks for your reply. I originally cloned the repo through Visual Studio. I.e New Project -> Clone => paste Git remote repository url (which is in Azure Devops). This project was an existing Aspire project. I then ran: azd auth login => (Successfully logged in) azd init => (Successfully created azure.yaml file and md file). azd infra synth => (Created Infra folders successfully) azd up (Successfully deployed all projects to Azure Portal) azd pipeline config --provider azdo -e test => I generated full access PAT, then this is where I got the error.

What is the best way to fix this? (or do it another way?)

vhvb1989 commented 2 months ago

@pbusfield , when you cloned the repo using Visual Studio, the git remote (for your project locally) is set to that repository, which you might not be the owner. In that case, you need to disconnect from that repo and connect a repo you own.

To disconnect from the template's repository (after doing a manual clone with VS or using git directly), you can run git remote remove origin.

If you initially run azd init -t <git remote repository url> (instead of using VS to clone the git remote repo url), azd takes care of cloning the repository and disconnecting your project from the template's repo.

Once disconnected, running azd pipeline config will help you to connect your local repo to a new or existing repo where you are the owner (where your PAT has access to).

pbusfield commented 2 months ago

Thanks @vhvb1989 I did what you said, and ran azd init -t <git remote repository url> It successfully cloned my repo. I noticed that only a azure.yaml file was created in the root, and no next-steps.md? The content of the azure.yaml file is different to previous runs:

new content:

# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json

name: APPName

original content:

name: APPName
services:  
  app:
    language: dotnet
    project: .\APPName.AppHost\APPName.AppHost.csproj
    host: containerapp

It didn't pick up my Aspire host under services?

Also, then when I run: azd up I get an error: ERROR: error executing step command 'provision': initializing provisioning manager: failed to compile bicep template: failed running bicep build: exit code: 1, stdout: , stderr: An error occurred reading file. Could not find a part of the path 'C:\ORG\APP\infra\main.bicep'.

I confirm there is no infra folder in the root, unlike other runs of the command previously.

So then I try to synthesize the infrastructure: azd infra synth (because this is how I created the infra folders in earlier runs) and get the error: (x) Failed: Synthesizing infrastructure

ERROR: this project does not contain any infrastructure to synthesize.

Any ideas? Thanks in advance.

vhvb1989 commented 2 months ago

@pbusfield , it looks like the repository you are cloning (the template) does not have an azure.yaml on the root. Can you check if the azure.yaml is inside the AppHost folder?

Aspire projects supports having the azure.yaml at the root of you repo or directly inside the AppHost project.

I've created this issue https://github.com/Azure/azure-dev/issues/4171 b/c azd init -t repo-url is not handling correctly the scenario where the azure.yaml is not at the root.

As a workaround, please manually delete the azure.yaml file from the root. If there is an azure.yaml inside the AppHost folder, cd to the AppHost folder and run azd from there. If there is not azure.yaml in AppHost folder, run azd init from the root to let azd to auto-detect the Aspire project and self-create a valid azure.yaml file.

pbusfield commented 2 months ago

@vhvb1989 Hi Victor,

I did run azd init -t <git remote repository url> from the root.

It clones the repo, and creates the azure.yaml at the root of the project (and only the root directory). There is no azure.yaml file in the AppHost directory (which is not the root directory). App.AppHost and App.ServiceDefaults folders both sit in the root, same folder as the .SLN file. The contents of the azure.yaml file in the root is only this:

# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json

name: APPName