0

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

enter image description here

Command 2:

az functionapp deployment source config-zip -g osh-poc-rg -n demo-funcapp-test --src $ZIP_URL

enter image description here

Command 3:

az webapp deploy --name demo-funcapp-test --resource-group osh-poc-rg --type zip --src-url $ZIP_URL --async false

enter image description here

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}' }}"

enter image description here

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. enter image description here

6
  • az webapp deployment source config-zip --name demo-funcapp-test --resource-group osh-poc-rg --src $ZIP_URL > Here ZIP URL Seems to be of c:\\Users. You can add the zip file as a blob inside a storage container and then create SAS token URL with the zipped blob and add it in this ZIP_URL Commented Dec 5, 2023 at 9:12
  • As your function is behind a private endpoint, You can add one VM in the same VNet as your private function app and then add that VM as a self hosted agent in your azure devops, Then run this az functionapp deployment source config-zip -g siliconrg54 -n siliconfunc65 --src "Syste.DefaultWorkingDirectory/funcapp.zip" inside your Devops cli task given your zipped folder is in azure repos Commented Dec 5, 2023 at 9:15
  • If your function app and storage is publicly enabled, Refer my SO thread answer here -stackoverflow.com/questions/76296061/… Commented Dec 5, 2023 at 9:15
  • @SiddheshDesai I tried alternative approach you mentioned such as add VM and use it as self hosted agent. I did the same and deployed function with azure cli task az functionapp deployment source config-zip -g siliconrg54 -n siliconfunc65 --src "Syste.DefaultWorkingDirectory/funcapp.zip" but the function is not showing up in Azure portal . I updated my question with snapshots.:( Commented Dec 5, 2023 at 15:06
  • If you are using Azure python Functions v2 make sure to have this setting -AzureWebJobsFeatureFlags EnableWorkerIndexing > Reference my So answer -stackoverflow.com/questions/76559759/… Commented Dec 6, 2023 at 12:29

1 Answer 1

0

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.

Bad Request({"error":{"code":"BadRequest","message":"System.ArgumentException: Invalid '/home/azureadminuser/myagent/_work/r1/a/_POCPrivateEndpoints-CI/drop/build.zip' packageUri in the JSON request\r\n   at Kudu.Services.Deployment.PushDeploymentController.<PushDeployAsync>d__16.MoveNext() in C:\\Kudu Files\\Private\\src\\master\\Kudu.Services\\Deployment\\PushDeploymentController.cs:line 474"}})

enter image description here

Changes done to CI pipeline:

using Pipeline Copy file task, I to make sure there is no build folder inside it.

enter image description here

Next In archive files Task i modified rootFolderOrFile to $(build.artifactstagingdirectory)/build

And it worked like a champ :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.