I am basically using the standard template for "Deploy Python app to Azure Functions App". Azure Function plan is Flex Consumption.
Here is the code snippet for deploying the python app:
- name: 'Run Azure Functions Action'
uses: Azure/functions-action@v1
id: fa
with:
app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }}
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
sku: 'flexconsumption' # Parameter required when using a publish profile with Flex Consumption
publish-profile: ${{ secrets.AZURE_CREDENTIALS }} # Remove publish-profile to use Azure RBAC
The job ends successful with:
Package deployment using One Deploy initiated. Deploy logs can be viewed at https://xxx.scm.azurewebsites.net/api/deployments/xxx/log Successfully deployed web package to Function App.
However afterwards the function list in Azure is empty:
The deployment is initiated, since previous functions deployed through VSC are deleted.
Deployment logs within Azure are not available:
"message": "The logs you are looking for were not found. In consumption plans, the instance will be recycled and logs will not be persisted after that. If you want them to be persisted ensure that Application Insights is enabled. See the Deployment Logs section here for more info: https://aka.ms/flex-deployments".
In Application Insights I cannot find any logs and to access Deployment Center->Logs in Azure portal I would first need to authenticate with Github.
Edit: I tested authenticating in Deployment Center. Using both Azure's auto-generated workflow and mine results in no errors, however in both cases, the function does not appear in the list of the function app. The logs in Deployment Center show that it worked:
Status: success (active)
"message": "Finished deployment pipeline.",
"message": "FunctionHostSyncTrigger, statusCode = OK",
"message": "Performed sync triggers successfully.",
Do you have any idea?
Sharing our findings here also to help the community.
The issue occurs because the GitHub Actions workflow does not include a prebuild step, and remote build is not enabled.
When deploying Python apps to Azure Functions with Flex Consumption, you must either:
Prebuild the dependencies in your GitHub Actions pipeline before deployment, or
Enable remote build, allowing Azure to handle the build process.
If you want to handle the build process in your pipeline, ensure that dependencies are installed and included in the deployment package:
- name: Create and start virtual environment
run: |
python -m venv venv
source venv/bin/activate
- name: Install dependencies
run: pip install -r requirements.txt -t .
This ensures that all dependencies are packaged before deployment.
If you are not prebuilding dependencies in the pipeline, enable remote build in the deployment step:
- name: 'Deploy to Azure Functions'
uses: Azure/functions-action@v1
with:
app-name: 'fncapp-fetchgitdata-dev'
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
remote-build: true
This allows Azure to install dependencies during deployment.
GitHub Actions for Azure Functions - Parameters
After applying either of these solutions, redeploy your function, and it should appear correctly in the Azure portal.
Hope this helps! 🚀 Let me know if you have any further questions.