microsoft / azure-pipelines-tasks

Tasks for Azure Pipelines
https://aka.ms/tfbuild
MIT License
3.5k stars 2.61k forks source link

[BUG]: 'Publish failed' for deploying new Zip Files to Azure Linux Functions App (restart required before this works) #19272

Open mrowles opened 1 year ago

mrowles commented 1 year ago

New issue checklist

Task name

Deploy Function App

Task version

No response

Issue Description

I have to restart my Azure Linux Functions App before I can redeploy using Zip File deploys. I have read that this is due to file locks, but the fixes I've attempted to use do not work. Hopefully someone from the Azure Functions team sees this and can assist.

I use the Terraform CDK to do this deployment - but this shouldn't matter as the underlying process is the same, but here is the code just in case:

    ...
    this.servicePlan = new ServicePlan(this, 'sp', {
      name: 'my-app',
      location: 'eastus',
      resourceGroupName: 'some-resource-group',
      osType: 'Linux',
      skuName: 'EP1', // have tried other plans such as 'EP1', 'EP3' etc.
    });

    new LinuxFunctionApp(this, 'lfa', {
      dependsOn: [
        this.servicePlan,
        this.applicationInsights,
        this.storageAccount,
      ],

      name: 'my-app',
      location: 'eastus',
      resourceGroupName: 'some-resource-group',
      servicePlanId: this.servicePlan.id,
      storageAccountName: this.storageAccount.name,
      storageAccountAccessKey: this.storageAccount.primaryAccessKey,
      functionsExtensionVersion: '~4',
      httpsOnly: true,
      zipDeployFile: 'path/to/package.zip',

      appSettings: {
        AZURE_STORAGE_CONNECTION_STRING: this.azureStorageConnectionString.value,
        FUNCTIONS_WORKER_RUNTIME: 'node',
        MSDEPLOY_RENAME_LOCKED_FILES: '1', // this does not fix it!
        WEBSITE_RUN_FROM_PACKAGE: '0', // this does not fix it!
        SCM_DO_BUILD_DURING_DEPLOYMENT: 'true',
        AzureWebJobsFeatureFlags: 'EnableWorkerIndexing',
        WEBSITES_ENABLE_APP_SERVICE_STORAGE: 'false',
      },

      siteConfig: {
        applicationInsightsConnectionString: this.applicationInsights.connectionString,
        applicationInsightsKey: this.applicationInsights.instrumentationKey,
        applicationStack: {
          nodeVersion: '18',
        },
        alwaysOn: false,
        elasticInstanceMinimum: 1,
        healthCheckPath: '/api/health',
        appCommandLine: 'node dist/index.js',
      },
    });

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

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

Linux

Relevant log output

Error: publishing source (assets/product-functions-ta/XXXAAADDD123/functions.zip) to site product-functions (Resource Group product-group): waiting for Zip Deployment to complete

Full task logs with system.debug enabled

No response

Repro steps

No response

FinVamp1 commented 9 months ago

@mrowles do you have a date and time for when this happens? You've opened this on the Azure Pipelines task and from the Terraform Template it looks like you are just using ZipDeploy directly via the extension.