I had developed azure function with private endpoint(disabled public access) HTTP Trigger
using .NET Core C#
.
Since inbound traffic for function , storage is cut off with internet access, I published my ZIP to a storage account(Newly created apart of storage that linked to function app and public enabled) via build(CI) pipeline and fetching the same ZIP file in release pipeline to deploy.
ZIP_URL : I can see ZIP URL with SAS token attached in logs.
I tried below commands for ZIP deployment in Azure CLI Task
but none are helping me. So i tried to run locally in my machine and getting different issues as shown below respectively.
Command 1:
az webapp deployment source config-zip --name demo-funcapp-test --resource-group osh-poc-rg --src $ZIP_URL
Command 2:
az functionapp deployment source config-zip -g osh-poc-rg -n demo-funcapp-test --src $ZIP_URL
Command 3:
az webapp deploy --name demo-funcapp-test --resource-group osh-poc-rg --type zip --src-url $ZIP_URL --async false
Command 4:
az rest --method PUT --uri https://management.azure.com/subscriptions/55555c7b-1f7a-43a1-a90f-dee45a2f6262/resourceGroups/osh-poc-rg/providers/Microsoft.Web/sites/demo-funcapp-test/extensions/onedeploy?api-version=2022-03-01 --body "{'properties': {'type': 'zip','packageUri': '${ZIP_URL}' }}"
Updated: After creating VM with same VNET as function app and modifying agent to Self host, I successfully abled to deploy but functions are not showing in Azure Portal.
I finally understood the root cause of issue.
The problem lies in zip file that build through CI pipeline. The zip file folder structure is incorrect.
ZIP file and folder structure before Issue fix: The azure function app code files resides inside
build
folder that downloaded build.zip artifact from build pipeline as show in below screenshot.Azure CLI task in unable to parse and deploy ZIP file, I see below log information in release logs file.
Changes done to CI pipeline:
using
Pipeline Copy file task
, I to make sure there is nobuild
folder inside it.Next In archive files Task i modified
rootFolderOrFile
to$(build.artifactstagingdirectory)/build
And it worked like a champ :)