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

[BUG]: AzureFunctionApp@2 recommending to add a variable that it removes #18970

Open
1 of 4 tasks
israelhdz08 opened this issue Sep 13, 2023 · 25 comments
Open
1 of 4 tasks

Comments

@israelhdz08
Copy link

israelhdz08 commented Sep 13, 2023

Task name

AzureFunctionApp

Task version

2

Environment type (Please select at least one enviroment where you face this issue)

  • Self-Hosted
  • Microsoft Hosted
  • VMSS Pool
  • Container

Azure DevOps Server type

Azure DevOps Server (Please specify exact version in the textbox below)

Azure DevOps Server Version (if applicable)

No response

Operation system

Windows 11

Task log

Got service connection details for Azure App Service:'<FunctionName>'
NOTE: Skipping AzureWebJobsStorage connection string validation since Key Vault reference is used.
Deleting App Service Application settings. Data: ["WEBSITE_RUN_FROM_ZIP","WEBSITE_RUN_FROM_PACKAGE"]
App Service Application settings are already present.
Validating deployment package for functions app before Zip Deploy
##[warning]"ZipDeploy Validation WARNING: It is recommended to set app setting WEBSITE_RUN_FROM_PACKAGE = 1 unless you are targeting one of the following scenarios: 1. Using portal editing. 2. Running post deployment scripts. 3. Need write permission in wwwroot. 4. Using custom handler with special requirements. NOTE: If you decide to update app setting WEBSITE_RUN_FROM_PACKAGE = 1, you will have to re-deploy your code. "
Package deployment using ZIP Deploy initiated.
....

The task first deletes the WEBSITE_RUN_FROM_PACKAGE variable from the Azure function, then it complains that it should exist.

@FinVamp1
Copy link
Contributor

Hi there, thanks for reporting this. Can you share your YAML file?

@israelhdz08
Copy link
Author

  task: AzureFunctionApp@2
  displayName: 'Deploy function'
  inputs:
    connectedServiceNameARM: 'ServiceConnector' 
    appType: 'functionApp' 
    appName: 'functionName' 
    deployToSlotOrASE: true
    resourceGroupName: 'resourceGroup' 
    slotName: 'rc'
    package: '$(System.DefaultWorkingDirectory)/function.zip'
    deploymentMethod: 'zipDeploy'

@FinVamp1
Copy link
Contributor

Hello, @israelhdz08 in order for this to be a consistent experience we need to carry out the following steps.

  1. Check the App Settings and remove any old app Settings that may conflict with the planned deployment options.
  2. Validate the App Configuration to ensure that the app is ready for Deployment and log the warning messages. For this we call an endpoint on the Kudu\SCM Site "/api/zipdeploy/validate"
  3. Before deploying the Zip Deploy package we will set back WEBSITE_RUN_FROM_PACKAGE=1 or URL depending on the scenario.

As the user owns the App Settings we need to follow this order to ensure that the app settings are configured correctly and to support moving from Run From Package =1 from Run From Package =URL.

I can see how this might be confusing and if you have any suggestions about how you would like to see this presented.
We may have to think about if this could affect other scenarios.

Adding @patelchandni as well.

@HaochenQ
Copy link

HaochenQ commented Feb 2, 2024

Hi,

I also face the same issue.

Occasionally, I have the below warning with this Function task.
image
##[warning]"ZipDeploy Validation WARNING: It is recommended to set app setting WEBSITE_RUN_FROM_PACKAGE = 1 unless you are targeting one of the following scenarios: 1. Using portal editing. 2. Running post deployment scripts. 3. Need write permission in wwwroot. 4. Using custom handler with special requirements. NOTE: If you decide to update app setting WEBSITE_RUN_FROM_PACKAGE = 1, you will have to re-deploy your code. "

I am using AUTO-DETECT as the deployment method.

- task: AzureFunctionApp@2
    condition: eq('${{ parameters.action }}', 'create')
    inputs:
      connectedServiceNameARM: '${{parameters.connectionName}}'
      appType: 'functionApp'
      appName: '$(FunctionAppName)'
      package: '$(Pipeline.Workspace)/**/*.zip'
      appSettings:
        '
        '
      deploymentMethod: 'auto'

When I see this error, although the deployment is successful the content of my function is not updated so I have a re-run the pipeline and it usually fixes the issue automatically.

Cheers,

@FinVamp1
Copy link
Contributor

FinVamp1 commented Feb 6, 2024

This is in our backlog. Will check to see what improvements we could make to help this.

@RobinDijkstra
Copy link

RobinDijkstra commented Mar 6, 2024

Same here, this seems more like a bug. We're using deployment method 'runFromPackage'.
Whenever we see this warning, there's nothing deployed although the task reports that the web package has been deployed. When re-running the pipeline stage, the warning does not appear and the deploy goes fine.

   - task: AzureFunctionApp@2
      displayName: 'Deploy FunctionApp'
      inputs: 
        azureSubscription: '${{ parameters.azureSubscription }}'
        appType: 'functionApp'
        appName: '${{ parameters.resourceName }}'
        deployToSlotOrASE: true
        resourceGroupName: '${{ parameters.resourceGroupName }}'
        slotName: 'deployment'
        package: '${{ parameters.packagePath }}'
        deploymentMethod: 'runFromPackage'

Task log:

Starting: Deploy FunctionApp

Task : Azure Functions Deploy
Description : Update a function app with .NET, Python, JavaScript, PowerShell, Java based web applications
Version : 2.231.0
Author : Microsoft Corporation
Help : https://aka.ms/azurefunctiontroubleshooting

Got service connection details for Azure App Service:'xyz'
Updating App Service Application settings. Data: {"WEBSITE_RUN_FROM_PACKAGE":"1"}
Deleting App Service Application settings. Data: ["WEBSITE_RUN_FROM_ZIP"]
Updated App Service Application settings and Kudu Application settings.
Validating deployment package for functions app before Zip Deploy
##[warning]"ZipDeploy Validation WARNING: It is recommended to set app setting WEBSITE_RUN_FROM_PACKAGE = 1 unless you are targeting one of the following scenarios: 1. Using portal editing. 2. Running post deployment scripts. 3. Need write permission in wwwroot. 4. Using custom handler with special requirements. NOTE: If you decide to update app setting WEBSITE_RUN_FROM_PACKAGE = 1, you will have to re-deploy your code. "
Package deployment using ZIP Deploy initiated.
Deploy logs can be viewed at https://xyz-deployment.scm.azurewebsites.net/api/deployments/abc/log
The web package has been deployed to App Service. Please note that the package mount or extraction errors will be logged in the deployment logs in the location above.
NOTE: Run From Package makes wwwroot read-only, so you will receive an error when writing files to this directory.
App Service Application URL: https://xyz-deployment.azurewebsites.net/
Finishing: Deploy FunctionApp

@Cuflee
Copy link

Cuflee commented Mar 12, 2024

We all of the sudden have the exact same issue @RobinDijkstra is mentioning above. Is there any update about his? We now don't dare to deploy anything to production in fear that we would have the same issue there as well.

We already rolled back any of our latest changes, but the issue seems Azure related. The functions all apear running, but they don't process any messages anymore after deploy.

Sometimes after rerunning the pipeline it works for several minutes and then breaks down again without any exception being logged (and the status still "running").

@FinVamp1
Copy link
Contributor

If you're still seeing this issue can you provide a Site Region and perhaps also check the AppSettings and let me know if you have this app setting? WEBSITE_ENABLE_SYNC_UPDATE_SITE = true or 1

@Mivaweb
Copy link

Mivaweb commented Mar 28, 2024

Since a couple of weeks, we are facing the same issue using the AzureFunctionApp@1 task. Redeploy fixes the issue. We are in the West Europe region and we have the following app settings active:

image

Yaml:

- task: AzureFunctionApp@1
  displayName: 'Azure Function App Deploy'
  inputs:
    azureSubscription: ${{ parameters.azServiceConnection }}
    appType: functionApp
    appName: 'func-${{ parameters.env }}-01'
    package: '$(Agent.BuildDirectory)\drop\Function.zip'

Task output with warning:

Updating App Service Application settings. Data: {"WEBSITE_RUN_FROM_PACKAGE":"1"}
Deleting App Service Application settings. Data: ["WEBSITE_RUN_FROM_ZIP"]
Updated App Service Application settings and Kudu Application settings.
Validating deployment package for functions app before Zip Deploy
##[warning]"ZipDeploy Validation WARNING: It is recommended to set app setting WEBSITE_RUN_FROM_PACKAGE = 1 u***ess

@Cuflee
Copy link

Cuflee commented Mar 28, 2024

We still have the issue but found a work-around by setting the pipeline into debug mode. We did this in order to troubleshoot the issue, but found that when the pipeline is running in debug mode the issue does not occur. Perhaps because of a process taking slightly longer in debug mode so something can complete. But it is strange that this all of the sudden started happening. All of the alterations mentioned within this thread were already tried and did not resolve the issue.

@RobinDijkstra
Copy link

We're also having the setting WEBSITE_ENABLE_SYNC_UPDATE_SITE = true on all out function apps and are also located in the West Europe region.

@ki-dro
Copy link

ki-dro commented May 3, 2024

We are also experiencing this issue. Are there any updates?

@FinVamp1
Copy link
Contributor

Hello all,

We've been investigating this issue and there is a timing issue where this can happen.

  1. AzureFunctionApp task sets WEBSITE_RUN_FROM_PACKAGE
  2. It calls the Validation Endpoint that exists on the Kudu\SCM website and this checks the app setting which isn't set yet.
  3. Validation fails but deployment succeeds albeit without using Run From Package.

Our investigations have identified that the AzureRMWebAppDeployment tasks have logic to detect this situation and will wait until Kudu\SCM has the right settings.

So if you're running into this issue please let us know if using the AzureRMWebAppDeployment task resolves the issue for you and we are planning to make this change into the Functions Task in the current sprint.

@komjera
Copy link

komjera commented May 22, 2024

We are also affected by this and when I tried to reproduce the issue with system.debug set to true I wasn't able to, which might indicate that this is indeed a timing issue that is "resolved" by slowing down the pipeline with debug mode.

@FinVamp1
Copy link
Contributor

FinVamp1 commented May 24, 2024

We have a tracking item for the fix for this here Update FunctionApp Task

@RobinDijkstra
Copy link

RobinDijkstra commented May 27, 2024

@FinVamp1 Thanks, I've found it but there is a character too many in the link.

@FinVamp1
Copy link
Contributor

@FinVamp1 Thanks, I've found it but there is a character too many in the link.

Thanks for the spot, I've updated the link.

@FinVamp1
Copy link
Contributor

#20191 has a fix for this.

@komjera
Copy link

komjera commented Aug 7, 2024

This occured today, not sure wether or not it's a regression since version 243 should have included the fix and we seem to be on 244.

image

@komjera
Copy link

komjera commented Sep 13, 2024

@FinVamp1, any updates on this? We are still experiencing the issue

@hajkio
Copy link

hajkio commented Sep 19, 2024

We are experiencing this issue too, affecting many of our deployments. Using version 2.244.5.
Is there any way to escalate this issue?

@ki-dro
Copy link

ki-dro commented Oct 18, 2024

@FinVamp1 @manolerazvan It has been over a year with this bug, when will this be fixed? As it is now we can't rely on this task at all since it seems to fail to often.
Does this mean Microsoft doesn't want us to use this task, and we should rely on the CLI instead?

@ki-dro
Copy link

ki-dro commented Oct 21, 2024

@patelchandni Is anyone from Microsoft looking at this issue?

@FinVamp1
Copy link
Contributor

Hello, @ki-dro I thought I had replied last week but it may have gone missed? Can you please check if you can send me Deployment logs with the Debug variable enabled and test again? The change should be in there and I was not able to reproduce this so I used the same logic as the AzureRMWebAppDeployment@4 task which should have helped. If you can't share publicly then please open a support case and I can work with you and support to look at this.

Finbar

@ki-dro
Copy link

ki-dro commented Oct 21, 2024

@FinVamp1 My deployment logs are the same as in #19909 (comment)

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

10 participants