Azure / Azure/azure-cli-extensions

[functionapp] az functionapp deployment source config-zip - does not deploy .zip as expected

Open
#10,024 2 comments 1 reaction 2 assignees Claimed by @a0x1ab View on GitHub
Auto-Assign Functions Service Attention
Dominant language
Python
Stars
454
Forks
1.7k
Avg merge
2d 19h
Merged PRs (30d)
64

Description

Source: https://github.com/Azure/azure-cli/issues/32128 (by @JamesPScottPharm3r)
Affected extension: `functionapp` (`src/functionapp/`)

---

<<>>
# Issue #32128 (by @JamesPScottPharm3r)
## Title
az functionapp deployment source config-zip - does not deploy .zip as expected

## Body
### Describe the bug

We've been using az functionapp deployment source config-zip to deploy our Azure functions to linux successfully for a year.

On the weekend when the Azure Function was deployed it was no longer finding any of our routes.

When I investigated further it was because the .zip file parameter (--src) was no longer using the contents of the specified .zip file. Instead it seemed to be writing the .zip filename string as txt in the .zip file and then that was the uploaded code. (So ya, no routes).

e.g. az functionapp deployment source config-zip --src ./someapp.zip

Instead of using the contents of the someapp.zip file it uploads a file named someapp.zip with ./someapp.zip echoed in its contents.

This was in production, so not a very ideal behavior to have all our function routes disappear.

The only way I could fix it was to hardcode a previous az cli version and run that through the github actions pipeline.

### Related command

az functionapp deployment source config-zip --src ./nolongerworks.zip

### Errors

No errors, it acts like everything is fine, but your Azure Function is dead in the water with no routes, paths etc.

### Issue script & Debug output

--debug

### Expected behavior

It should deploy as expected.

### Environment Summary

2.77.0 - latest version that would be deployed in github actions.

### Additional context

Should likely be fixed quickly before it impacts other customers too.

## Comments
### Comment by @yonzhan

Thank you for opening this issue, we will look into it.

### Comment by @github-actions[bot]
Here are some similar issues that might help you. Please check if they can solve your problem.
- #32044
------------

**Possible solution (Extracted from existing issue, might be incorrect; please verify carefully)**

### Solution 1:
I've temporarily worked around this in ADO classic releases by putting a task in the stage that just runs this: `pip install azure-cli==2.76.0` and it works for me.

**Reference**:
- https://github.com/azure/azure-cli/issues/32044#issuecomment-3274011392
### Solution 2:
As a workaround, this is what we're doing in our release pipelines. We're using the `Azure CLI` task then we use the azure cli docker image within the Inline Script within the task:

''' shell
docker run --rm \
-v "$AZURE_CONFIG_DIR":/root/.azure \
-v "$(System.DefaultWorkingDirectory)/_MyApp/drop":/workspace \
-w /workspace \
mcr.microsoft.com/azure-cli:2.76.0 \
az functionapp deployment source config-zip \
--name my-function \
--resource-group my-resource-group \
--src MyApp.zip \
--subscription my-subscription \
--debug
'''

**Reference**:
- https://github.com/azure/azure-cli/issues/32044#issuecomment-3274448111
### Solution 3:
If you need the downgrade script for in a dockerfile:

'''
# Install latest azure cli
RUN curl -sL https://aka.ms/InstallAzureCLIDeb | bash
# Downgrade it
RUN apt-get install -y --allow-downgrades azure-cli=2.76.0-1~bookworm
'''

The lsb (bookworm) can be different depending on your base image.

**Reference**:
- https://github.com/azure/azure-cli/issues/32044#issuecomment-3280114070

_Powered by [issue-sentinel](https://github.com/Azure/issue-Sentinel)_

### Comment by @microsoft-github-policy-service[bot]
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @AnatoliB, @Francisco-Gamino, @shreyabatra4.

### Comment by @microsoft-github-policy-service[bot]
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @AnatoliB, @Francisco-Gamino, @shreyabatra4.

### Comment by @martinjoshua
This issue also appears to be happening with the `--package-file` parameter of the `az batch application package create` command.

### Comment by @arto-pihlaja
We're experiencing the same. The linked issue also fits the symptoms.
Today as a workaround I switched to AzureFunctionApp@2 .
So, before we had
` - task: AzureCLI@2
displayName: Deploy function
inputs:
azureSubscription: '$(serviceConnection)'
scriptType: bash
scriptLocation: inlineScript
inlineScript: |
az functionapp deployment source config-zip -g ${{ parameters.resourceGroupName }} -n ${{ parameters.appName }} --src $(Pipeline.Workspace)/CI/drop/*.zip`
now we have
` - task: AzureFunctionApp@2
displayName: 'Deploy Azure Function App'
inputs:
azureSubscription: '$(serviceConnection)'
appType: 'functionAppLinux'
appName: '${{ parameters.appName }}'
package: '$(Pipeline.Workspace)/CI/drop/*.zip'
deploymentMethod: 'zipDeploy' `
I haven't yet tested everything, but at least the workaround deploys the functions.
<<>>

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.