azure-functions

Zip deploy of Azure function was a success but Functions in Azure is empty


Hi I have a Azure function timer which I am trying to deploy via ZIP deploy, it succeeds but Functions in Azure is empty.

enter image description here

The cmd I am using for the deployment is az functionapp deployment source config-zip -g $resourceGroupName -n $functionName --src $sourceZipPath

The JSON response from the cmd is as below.

{  "active": false,
  "author": "N/A",
  "author_email": "N/A",
  "complete": true,
  "deployer": "ZipDeploy",
  "end_time": "2022-03-25T12:37:54.9247211Z",
  "id": "373e929429a14bee8b6368949e922789",
  "is_readonly": true,
  "is_temp": false,
  "last_success_end_time": "2022-03-25T12:37:54.9247211Z",
  "log_url": "https://xxxx.scm.azurewebsites.net/api/deployments/latest/log",
  "message": "Created via a push deployment",
  "progress": "",
  "provisioningState": "Succeeded",
  "received_time": "2022-03-25T12:33:05.5662452Z",
  "site_name": "xxxx",
  "start_time": "2022-03-25T12:33:17.5130554Z",
  "status": 4,
  "status_text": "",
  "url": "https://xxxx.scm.azurewebsites.net/api/deployments/latest"
}

I can see all the files inside the file structure (screen shots below) enter image description here enter image description here

Not sure where I am going wrong. It works perfectly when deployed from Visual Studio 2019.

I did check on the post "https://stackoverflow.com/questions/64032902/az-functionapp-deployment-reports-success-but-functions-view-in-azure-is-empt" and followed the steps but no luck.

Can anyone suggest what else can I try.


Solution

  • I tried to reproduce the same issue while deploying the Azure Function using AZ CLI both from Local CLI and Azure CloudShell:

    az functionapp deployment source config-zip -g HariTestRG -n KrishNet6FuncApp --src "C:/Users/Hari/source/repos/DotNet6/TimerTrigger1205.zip"
    

    enter image description here

    enter image description here

    As Per this GitHub Discussion, I came to know that the command az functionapp deployment source config-zip having the issue with AZ CLI versions and tried by downgrading to 2.28 version of Azure CLI but not succeeded the desired result.

    Command to downgrade the Azure CLI version:

    $ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest -Uri https://azcliprod.blob.core.windows.net/msi/azure-cli-2.28.0.msi -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'; rm .\AzureCLI.msi
    

    Alternative workaround to this zip push deploy of Function Apps is using PowerShell Commands and working well.

    Updated Answer

    After enabling the application setting SCM_DO_BUILD_DURING_DEPLOYMENT to true and deploying the Azure Function Zip using AZ CLI, it deployed successfully and shows the functions in the Azure Portal along with the files in the wwwroot folder.

    enter image description here

    AZ CLI Command:

    az functionapp deployment source config-zip -g HariTestRG -n KrishNet6FuncApp --src "C:/Users/Hari/source/repos/DotNet6/TimerTrigger1205.zip"
    

    enter image description here

    From this Microsoft Documentation, we came to know that some deployment customization has to be done before deploying the Function App as a Zip Push, i.e., by default the app setting SCM_DO_BUILD_DURING_DEPLOYMENT is false which enables the continuous integration deployment.

    For the PowerShell Workaround, refer this GitHub Page.