2
votes

I'm deploying an azure function app from package (using this guide - https://docs.microsoft.com/en-us/azure/azure-functions/run-functions-from-deployment-package) - this deploys correctly. Yet I can't seem to get an update deployed. Even after I upload a new package, changes are not picked up by azure function app. I tried stopping/starting the app to no avail.

How can I force it to pick up changes?

6
The documentation says it requires a restart, is it not working ? do you have all the app settings configured on the portal ???Thomas
Everything is configured. Restart done multiple times - still not picking up changes.Aleks G
What's the value of WEBSITE_RUN_FROM_PACKAGE? 1 or sas url?Jerry Liu
@JerryLiu It is SAS url. It deployed correctly the first time round.Aleks G
@AleksG Have updated my answer, try cli command.Jerry Liu

6 Answers

3
votes

I ran into this issue with a newly deployed function using function v3, so this still seems to be an issue.

Short answer:
Remove the .zip in D:\home\data\SitePackages and then redeploy and your changes will get picked up.

Long answer

My setup is using ZIP deployment and WEBSITE_RUN_FROM_PACKAGE = 1.

It helps to know what happens when you use ZIP deployment:

  1. The zip file is not written to wwwroot of your site, but instead to D:\home\data\SitePackages (source: https://docs.microsoft.com/en-us/azure/azure-functions/run-functions-from-deployment-package)
  2. Then the contents of the zip file is mounted to D:\home\site\wwwroot and run from there.

For some reason, the .zip in D:\home\data\SitePackages was not being replaced, it was still the old version. To fix that, I used the Console of the App Service to delete the file before redeploying.

  1. Navigate to your App Service function and open the Console (under Development tools section)
  2. Run cd D:\home\data\SitePackages and then ls to see the files in the folder.
  3. Run a rm command to remove both the zip and text file.
  4. Redeploy your function, and you will see that changes are picked up.
2
votes

We had a very weird problem using Azure Function App Deploy from Azure DevOps.

This worked perfectly until we one day made some code changes to the Azure Function that worked locally but not on our dev server. We started looking at the .zip file and the release pipeline but everything looked good here. We could also see that nothing had changed in our azure-pipelines.yml or release pipeline:

enter image description here

Git command: git log -p azure-pipelines.yml

enter image description here

For releases we used the Azure Functions task by Microsoft Corporation.

enter image description here

Looking at the release logs everything seemed good as well:

enter image description here

We then logged in to Kudu (Advanced Tools) and used powershell to look at the files deployed.

https://<your-function>.scm.azurewebsites.net/DebugConsole/?shell=powershell

Running the command dir D:\home\site\wwwroot we could see that the files had not been updated and when we looked at dir D:\home\data\SitePackages we could not see a new .zip file either.

enter image description here

Confirmed wrong .zip by running the command Get-Content D:\home\data\SitePackages\packagename.txt to see which .zip is being used.

enter image description here

Then wen't back to Azure DevOps and tried to create a new release but the files still did not update. Then I tried to clone the Azure Function App Deploy step that had previously worked and disabled the other one. Tried a new release and now everything worked.

enter image description here

enter image description here

I think this must be a Microsoft bug since we did not really change any values at all. Hope this can help someone else and that Microsoft fixes this.

enter image description here

0
votes

If you replace old package using new one with the same package name(to leverage the same sas url), make sure the old one is overwritten. And you have to click the refresh button next to Function app to sync triggers along with the changes.

Update

I recommend using the publish command(func azure functionapp publish <functionAppName>) provided by Azure Function Core Tools(Cli). V2 Cli benefits from Run from package as well and automates the whole process for us(zip the folder, upload, create app setting, sync triggers).

The command get publishing info(username, password for deployment) first, then

  1. Archives function project.

  2. Uploads zip file(name is in the format of UTCTime-GUID.zip) to function-releases container in Storage account specified by AzureWebJobsStorage app setting.

  3. Create an app setting WEBSITE_RUN_FROM_ZIP(original name of WEBSITE_RUN_FROM_PACKAGE, both work) with SAS Url.

  4. Sync triggers to pick up changes.

0
votes

After all efforts, the only thing I really determined was that you need to restart - and then wait. About 15-20 minutes after restart the changes were automagically there.

0
votes

If you try to deploy with new JAR/ZIP to function-app , the changes will be reflected within 1-2 mins * Make sure that you are using correct value for WEBSITE_RUN_FROM_PACKAGE * Download the content from console and check whether its same or not

0
votes

I had the same problem, after changing the deployment to use WEBSITE_RUN_FROM_PACKAGE. I think the problem is that it is using the cached deployment tool, so it's using the previous deployment script, not a new one when you change how you want it to deploy.

If you look at the deploy log in azure devops there is a link to the deploy log in the kudu interface: enter image description here

I found this answer which explains how to fix it.