Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment fails from time to time as the actions fails to find the function App #116

Open
Michaelvsk opened this issue Feb 2, 2022 · 46 comments

Comments

@Michaelvsk
Copy link

Hi,
I am deploying a dotnet-isolated function app using .NET 6 and from time to time the deployment fails with the following error

Using RBAC for authentication, GitHub Action will perform resource validation.
##[debug]try-get AzureCLIAuthorizer
##[debug]"/usr/bin/az" account show
##[debug]"/usr/bin/az" cloud show
##[debug]"/usr/bin/az" account get-access-token
::add-mask::***
##[debug][GET] https://management.azure.com/subscriptions/***/resources?$filter=resourceType EQ 'Microsoft.Web%2FSites' AND name EQ '___FUNCTION__NAME___'&api-version=2016-07-01
Error: Execution Exception (state: ValidateAzureResource) (step: Invocation)
Error:   Resource ___FUNCTION__NAME___ doesn't exist.
Error:     Error: Resource ___FUNCTION__NAME___ doesn't exist.
    at Function.<anonymous> (/home/runner/work/_actions/Azure/functions-action/v1/node_modules/azure-actions-appservice-rest/Utilities/AzureResourceFilterUtility.js:21:23)
    at Generator.next (<anonymous>)
    at fulfilled (/home/runner/work/_actions/Azure/functions-action/v1/node_modules/azure-actions-appservice-rest/Utilities/AzureResourceFilterUtility.js:5:58)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
Error: Deployment Failed!
##[debug]Node Action run completed with exit code 1

I am using RBAC authentication via azure/login@v1. The service principal has contributor permission on the whole subscription.
When I use Re-run all jobs for the workflow run, then deployment usually works fine.

I am deploying the function app via terraform, before deployment runs. But it also fails, if the function app is already there and exists for hours. So doesn't seem to be some kind of "race condition".

As I deploy IaC via terraform using publish-profiles would be overly complicated I would say. There seems to be no native support in terraform's azurerm to get the profile.

@Michaelvsk Michaelvsk changed the title Deployment fails from time to time due as the actions fails to find the function App Deployment fails from time to time as the actions fails to find the function App Feb 3, 2022
@github-actions
Copy link

This issue is idle because it has been open for 14 days with no activity.

@github-actions github-actions bot added the idle label Feb 17, 2022
@jonas-lomholdt
Copy link

I'm also getting this. The function app is there, but it breaks during deployment

Error: Resource func-my-function doesn't exist.
    at Function.<anonymous> (/home/runner/work/_actions/Azure/functions-action/v1/node_modules/azure-actions-appservice-rest/Utilities/AzureResourceFilterUtility.js:21:23)
    at Generator.next (<anonymous>)
    at fulfilled (/home/runner/work/_actions/Azure/functions-action/v1/node_modules/azure-actions-appservice-rest/Utilities/AzureResourceFilterUtility.js:5:58)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

@jonas-lomholdt
Copy link

Redeploying it worked though. But then I hit the same issue in the next environment (test -> prod)

@github-actions github-actions bot removed the idle label Mar 3, 2022
@Michaelvsk
Copy link
Author

To bypass the issue I am querying the publish profile via az CLI for now. Here's an example:

- uses: azure/login@v1
  with:
  creds: <CREDENTIALS>

- name: Retrieve publish profile for deployment
  id: publishProfileRetrieval
  run: |
    publishProfiles=$(az webapp deployment list-publishing-profiles \
      --name "<FUNCTION APP NAME>" \
      --resource-group "<RESOURCE GROUP NAME>" \
      --subscription "<SUBSCRIPTION ID>" --xml)
    echo "::add-mask::$publishProfiles"
    echo "::set-output name=publishProfiles::$publishProfiles"

- name: 'Run Azure Functions Action'
  uses: Azure/functions-action@v1
  with:
    app-name: <FUNCTION APP NAME>
    package: <PATH TO DEPLOYMENT PACKAGE>
    publish-profile: ${{ steps.publishProfileRetrieval.outputs.publishProfiles }}

@Joaolfelicio
Copy link

Had the same issue, deleting the functions and re-running the pipeline did it, not the best solution in any case..

@github-actions
Copy link

This issue is idle because it has been open for 14 days with no activity.

@akbast
Copy link

akbast commented Apr 25, 2022

I am facing the same issue. Any news on this?

@Michaelvsk
Copy link
Author

I am confused, too and don't understand why this issue has been closed. I do understand that the error seems to come from a library used here. But as long as the library isn't fixed and this action not upgraded to use the fixed version, I see no reason to close this bug.

I would even contribute to the library but there are PRs open since 2020 so I fear a patch wouldn't be picked up anytime soon. :/

@patelchandni patelchandni reopened this May 4, 2022
@github-actions
Copy link

This issue is idle because it has been open for 14 days with no activity.

@github-actions github-actions bot added the idle label May 18, 2022
@akbast
Copy link

akbast commented Aug 17, 2022

@patelchandni any news on this?

@github-actions github-actions bot removed the idle label Aug 17, 2022
@github-actions
Copy link

This issue is idle because it has been open for 14 days with no activity.

@github-actions github-actions bot added the idle label Aug 31, 2022
@jannisrelakis
Copy link

This is still an issue. What about handling it instead of having the bots close it?

@jannisrelakis
Copy link

To bypass the issue I am querying the publish profile via az CLI for now. Here's an example:

- uses: azure/login@v1
  with:
  creds: <CREDENTIALS>

- name: Retrieve publish profile for deployment
  id: publishProfileRetrieval
  run: |
    publishProfiles=$(az webapp deployment list-publishing-profiles \
      --name "<FUNCTION APP NAME>" \
      --resource-group "<RESOURCE GROUP NAME>" \
      --subscription "<SUBSCRIPTION ID>" --xml)
    echo "::add-mask::$publishProfiles"
    echo "::set-output name=publishProfiles::$publishProfiles"

- name: 'Run Azure Functions Action'
  uses: Azure/functions-action@v1
  with:
    app-name: <FUNCTION APP NAME>
    package: <PATH TO DEPLOYMENT PACKAGE>
    publish-profile: ${{ steps.publishProfileRetrieval.outputs.publishProfiles }}

That didn't fix it for me. Thanks for the snippet though, I am using it regardless.

@github-actions github-actions bot removed the idle label Sep 9, 2022
@github-actions
Copy link

This issue is idle because it has been open for 14 days with no activity.

@github-actions github-actions bot added the idle label Sep 23, 2022
@github-actions
Copy link

github-actions bot commented Mar 6, 2023

This issue is idle because it has been open for 14 days with no activity.

@github-actions github-actions bot added the idle label Mar 6, 2023
@wbcapt
Copy link

wbcapt commented Mar 11, 2023

Thank you @Jtango18 !! Anything yet?

I'm also on ARM

@github-actions github-actions bot removed the idle label Mar 11, 2023
@Jtango18
Copy link

It's no longer repeatable from me after some changes by the support/ARM team. Can't state with 100% certainty that it's resolved. But works on my machine now 🤷‍♂️

@runeheidem
Copy link

To bypass the issue I am querying the publish profile via az CLI for now. Here's an example:

- uses: azure/login@v1
  with:
  creds: <CREDENTIALS>

- name: Retrieve publish profile for deployment
  id: publishProfileRetrieval
  run: |
    publishProfiles=$(az webapp deployment list-publishing-profiles \
      --name "<FUNCTION APP NAME>" \
      --resource-group "<RESOURCE GROUP NAME>" \
      --subscription "<SUBSCRIPTION ID>" --xml)
    echo "::add-mask::$publishProfiles"
    echo "::set-output name=publishProfiles::$publishProfiles"

- name: 'Run Azure Functions Action'
  uses: Azure/functions-action@v1
  with:
    app-name: <FUNCTION APP NAME>
    package: <PATH TO DEPLOYMENT PACKAGE>
    publish-profile: ${{ steps.publishProfileRetrieval.outputs.publishProfiles }}

Had similar issue with azure/webapps-deploy@v2 and by accident caused by frustrations ended up with the same solution.

@github-actions
Copy link

This issue is idle because it has been open for 14 days with no activity.

@github-actions github-actions bot added the idle label Mar 27, 2023
@kaluzaaa
Copy link

Any news about this?

@github-actions github-actions bot removed the idle label Mar 29, 2023
@tspascoal
Copy link

I can confirm this also happens with a function app created with Bicep (haven't yet figured out what unblocks it)

@github-actions
Copy link

github-actions bot commented May 8, 2023

This issue is idle because it has been open for 14 days with no activity.

@github-actions github-actions bot added the idle label May 8, 2023
@fleed
Copy link

fleed commented May 12, 2023

Same problem here

@github-actions github-actions bot removed the idle label May 12, 2023
@ranrsg
Copy link

ranrsg commented May 23, 2023

Same here.
In our case I see it is working just fine for existing function apps - but newly created ones are getting this 'Execution Exception (state: ValidateAzureResource) (step: Invocation)' and 'Resource FUNCTION__NAME doesn't exist' for almost one hour until it is finely working..

@ghost
Copy link

ghost commented May 25, 2023

In my case the issue is caused by a breaking change introduced in Terraform 0.14 mentioned in the following issue hashicorp/terraform#27100. In line 7776 on the below screenshot there is the exact URL called from within the functions action and there are additional encoded quotation marks in the function app name
image
I called the same URL using postman and the resource is not returned which is the direct reason for the failure.

The only change I had to make was passing the quoted value through jq function like this:
image

@github-actions
Copy link

github-actions bot commented Jun 8, 2023

This issue is idle because it has been open for 14 days with no activity.

@github-actions github-actions bot added the idle label Jun 8, 2023
@bachar-senno
Copy link

bachar-senno commented Jan 9, 2024

Same issue here. It was working couple of days ago, and now suddenly, resource doesn't exist. Not sure where to go from here. Anyone found a viable solution?

I tried passing the publish profile as suggested, it no longer says resource doesn't exist, and the deployment succeeds on paper, but I still am unable to find my functions in my function app after it finishes.

@github-actions github-actions bot removed the idle label Jan 9, 2024
Copy link

This issue is idle because it has been open for 14 days with no activity.

@github-actions github-actions bot added the idle label Jan 23, 2024
@BenjaminNiemann
Copy link

Same issue here with a new azure function. Created the function yesterday and now the same issue. This -> https://learn.microsoft.com/en-us/troubleshoot/azure/devops/resource-not-exist-error-services-deployment cant be the solution, because of the delay the function was created a day before. Is use a managed idenitiy to deploy. May permissons are not set?

@skvark
Copy link

skvark commented Apr 3, 2024

Same issue here too...

suny-am added a commit to suny-am/gh-api-token-provider that referenced this issue Apr 6, 2024
Testing latest version of functions-action due to bug
Azure/functions-action#116
@rbourdon
Copy link

I experienced this while setting up CD for an existing function app slot, using the generated workflow file. I used the token retrieved in the azure/login action (using the managed identity azure generated) to call the endpoint that the azure/functions-action calls and confirmed the response was an empty array. After I gave the generated managed identity the Website.Contributor role for the main function app (in addition to the slot), deployment succeeded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests