Azure-Functions icon indicating copy to clipboard operation
Azure-Functions copied to clipboard

Azure portal not showing any functions, when deployed from zip with github or az CLI

Open SamVanhoutte opened this issue 1 year ago • 14 comments
trafficstars

Hello all,

Issue description

When I deploy my Azure Function project (dotnet isolated net80) from my IDE (in my case Rider) to a new Function App / Service plan, I can nicely see the function that belongs to the project, when I navigate to the portal. However, when I deploy that same project from Github pipeline (using the ``action), but also from the az cli, using zip-deploy, I don't see the Function appear in the portal.

The two results are screenshotted here (difference is in the bottom part of the screenshots: MeterImporter function visible in the top, not at the bottom)

image

Things I verified

I made sure the following settings are double checked and compared between the working app & the app without functions:

  • App plan Linux - Basic
  • FUNCTIONS_WORKER_RUNTIME: dotnet-isolated
  • FUNCTIONS_EXTENSION_VERSION: ~4
  • General Settings > Stack Settings > .NET Version: .NET 8 Isolated
  • All App Service Plans are equal

Findings through kudu

  • I also compared the contents of wwwroot of the working & non-working Function app. And they are exactly the same.
  • I checked the app settings in Kudu and some settings were available in my Function App, but not in the working one. (though no idea how I can remove them, to see if they have effect):
    • "REMOTEDEBUGGINGVERSION": "16.0.33328.57"
    • "FUNCTIONS_RUNTIME_SCALE_MONITORING_ENABLED": "0"
    • "WEBSITE_AUTH_LOGOUT_PATH": "/.auth/logout"
    • "WEBSITE_AUTH_AUTO_AAD": "False"

Logs of the function in Azure

A snippet that I see in the logs (containing an error) could be relevant?

/appsvctmp/volatile/logs/runtime/42afc2e56f4f8255275996a360f39ea1b9c6e9b3dedf656a00cba5fc0ef33558.log 
2024-02-15T07:24:41.957479280Z: [ERROR]  cp: target '/etc/pki/ca-trust/source/anchors' is not a directory
2024-02-15T07:24:48.622588020Z: [INFO]  Updated CA certificates
2024-02-15T07:24:54.491532659Z: [INFO]  {"EventId":0,"LogLevel":"Information","Category":"Program","Message":"Entering app startup."}
2024-02-15T07:24:58.584000849Z: [INFO]  Hosting environment: Production
2024-02-15T07:24:58.609875324Z: [INFO]  Content root path: /app
2024-02-15T07:24:58.609916928Z: [INFO]  Now listening on: http://[::]:8081
/appsvctmp/volatile/logs/runtime/d809e5f677d0b641814804b91e01a791ee7a60aab76696381a2b231a3d55a6e3.log 
2024-02-15T07:17:01.688739094Z: [INFO]  Starting OpenBSD Secure Shell server: sshd.
2024-02-15T07:17:30.887778269Z: [INFO]  Hosting environment: Production
2024-02-15T07:17:30.888191511Z: [INFO]  Content root path: /azure-functions-host
2024-02-15T07:17:30.888201912Z: [INFO]  Now listening on: http://[::]:80
2024-02-15T07:17:30.915335747Z: [INFO]  Application started. Press Ctrl+C to shut down.

Code snippets

These are the code snippets that I believe are relevant.

Bicep files for Azure Functions & app

Function-app.yaml. (being called from the main bicep file)

param location string
param environmentAcronym string
param locationAcronym string
param functionName string
param functionsStorageAccountName string = '${locationAcronym}${environmentAcronym}companionstafx'
param applicationInsightsConnextionString string
param applicationInsightsInstrumentationKey string
param appSettings array

var funtionAppServicePlanName = '${locationAcronym}-${environmentAcronym}-companion-plan-${functionName}'
var functionAppName = '${locationAcronym}-${environmentAcronym}-companion-func-${functionName}'

resource functionsStorageAccount 'Microsoft.Storage/storageAccounts@2021-06-01' = {
  name: functionsStorageAccountName
  location: location
  sku: {
    name: 'Standard_LRS'
  }
  kind: 'StorageV2'
  properties: {}
}

resource functionAppPlan 'Microsoft.Web/serverfarms@2023-01-01' = {
  name: funtionAppServicePlanName
  kind: 'functionapp,linux'
  location: location
  properties: {
    perSiteScaling: false
    elasticScaleEnabled: false
    maximumElasticWorkerCount: 1
    isSpot: false
    reserved: true
    isXenon: false
    hyperV: false
    targetWorkerCount: 0
    targetWorkerSizeId: 0
    zoneRedundant: false
  }
  
  sku:{
    name: 'B1' // Basic 1
    tier: 'Basic'
  }
}

var functionAppSettings = [
  {
    name: 'AzureWebJobsStorage'
    value: 'DefaultEndpointsProtocol=https;AccountName=${functionsStorageAccount.name};AccountKey=${listKeys(functionsStorageAccount.id,'2019-06-01').keys[0].value}'
  }
  {
    name: 'AzureWebJobsDashboard'
    value: 'DefaultEndpointsProtocol=https;AccountName=${functionsStorageAccount.name};AccountKey=${listKeys(functionsStorageAccount.id,'2019-06-01').keys[0].value}'
  }
  {
    name: 'FUNCTIONS_EXTENSION_VERSION'
    value: '~4'
  }
  {
    name: 'FUNCTIONS_WORKER_RUNTIME'
    value: 'dotnet-isolated'
  }
]

var applicationInsightsAppSettings = applicationInsightsInstrumentationKey != null ? [
  {
    name: 'APPLICATIONINSIGHTS_CONNECTION_STRING'
    value: applicationInsightsConnextionString
  }
] : [ ]

resource functionApp 'Microsoft.Web/sites@2023-01-01' = {
  name: functionAppName
  location: location
  kind: 'functionapp,linux'
  identity: {
    type: 'SystemAssigned'
  }
  properties: {
    serverFarmId: functionAppPlan.id
    httpsOnly: true
    siteConfig: {
      alwaysOn: true
      linuxFxVersion: 'DOTNET-ISOLATED|8.0'
      use32BitWorkerProcess: false
      netFrameworkVersion: 'v8.0'
      appSettings: concat(functionAppSettings, applicationInsightsAppSettings, appSettings)
    }
  }
}

output principalId string = functionApp.identity.principalId
output tenantId string = functionApp.identity.tenantId

Github workflow sections

The following section shows how I build/zip and publish the app, in a github workflow action

Build

inputs:
  functionProjectFolderName:
    type: string
    required: true
  buildConfiguration:
    type: string
    default: Release
  sourceFolder:
    type: string
    default: 'src'
  outputFolder:
    type: string
    default: 'output'

runs:
  using: "composite"
  steps:
    - name: 'Build and package code for function ${{ inputs.functionProjectFolderName }}'
      shell: bash
      run: |
        publishfolder="${{ github.workspace }}/${{ inputs.outputFolder }}/${{ inputs.functionProjectFolderName }}"
        mkdir -p $publishfolder
        cd $publishfolder
        dotnet build ${{ github.workspace }}/${{ inputs.sourceFolder }}/${{ inputs.functionProjectFolderName }} --configuration ${{ inputs.buildConfiguration }} --output ./output
    - name: 'Package Azure Function build'
      uses: actions/upload-artifact@v2
      with:
        name: ${{ inputs.functionProjectFolderName }}-function
        path: '${{ github.workspace }}/${{ inputs.outputFolder }}'
        if-no-files-found: error

Deploy, using Azure RBAC

name: 'Deploy Companion function app'

inputs:
  functionProjectFolderName:
    type: string
    required: true
  functionName:
    type: string
    required: true

runs:
  using: "composite"
  steps:
    - name: Download function code from pipeline artifact
      uses: actions/download-artifact@v3
      with:
        name: ${{ inputs.functionProjectFolderName }}-function
        path: ./artifacts/${{ inputs.functionProjectFolderName }}-function
    - name: Deploy the function
      uses: azure/functions-action@v1
      with:
        app-name: ${{ inputs.functionName }}
        package: './artifacts/${{ inputs.functionProjectFolderName }}-function'

Az CLI code

az functionapp deployment source config-zip -g weu-dev-rg-backend -n weu-dev-companion-fxname --src output.zip

SamVanhoutte avatar Feb 14 '24 13:02 SamVanhoutte

Thanks for reporting.can you try with azure portal option and please share the func app name,invocation id,timestamp,logs screenshot..Thanks

bhagyshricompany avatar Mar 19 '24 08:03 bhagyshricompany

I'm facing the same issue with a Python function. Deployment works as expected on VSCode, but the same thing happens when using azure-cli or GH Actions (also, besides the function names not appearing in the Azure Portal, my HTTP trigger functions 404)

piero2c avatar Mar 19 '24 17:03 piero2c

I'm facing the same issue with a Python function. Deployment works as expected on VSCode, but the same thing happens when using azure-cli or GH Actions (also, besides the function names not appearing in the Azure Portal, my HTTP trigger functions 404)

Exactly the same. Function App not appear at all. OTOH, I'm with TimerTrigger Python Function.

FranckRedeo avatar Mar 19 '24 20:03 FranckRedeo

I had the issue with our Functions app (dotnet-isolated) after upgrading from dotnet7 to dotnet8. I tried a variety of fixes, including changing some versions of some of the dependent Azure Functions SDK projects as I'd seen some threads indicate that was their fix. Nothing was working.

Upon attempting to just deploy from VS, I found that the deployment worked. Weird. So I went and grabbed the deployed artifacts from our AzRepos pipeline, and the VS deployed package, and diff'd them (Beyond Compare FTW).

Most of the differences were seemingly noise/meaningless, except for one thing. The worker.config.json file that is built was deployed from our Pipeline as {WorkerRoot}<our-entry-assembly-name-without-extension>, but when published from VS was simply dotnet. I tossed this into our deployment yaml (where is our build artifact), for right before the deployment task:

  - task: PowerShell@2
    name: update_worker_config
    displayName: 'Update Worker Config'
    inputs:
      targetType: 'inline'
      script: |
        $configPath = "$(Pipeline.Workspace)/build/output/<artifact-name>/worker.config.json"
        $config = Get-Content -Path $configPath -Raw | ConvertFrom-Json
        $config.description.defaultExecutablePath = 'dotnet'
        $config | ConvertTo-Json | Set-Content -Path $configPath

And it worked!

Interestingly enough however, I just looked at the artifacts for our latest build pipeline (only 1 non-relevant code file has changed in the mean time), and it appears that the value now being artifacted IS simply dotnet, so looks like this may have been resolved with an update, though I don't immediately see any recently released SDK updates for AzFunctions 🤷‍♂️.

tostringtheory avatar Mar 19 '24 21:03 tostringtheory

I'm facing the same issue, but I cannot understand if it's a misconfiguration. Mine is an http triggered python function

matteomessmer avatar Mar 22 '24 08:03 matteomessmer

have the same

tdysko-cf avatar Mar 28 '24 08:03 tdysko-cf

I am facing the same issue here. Whenever I add some code to interact with a database, the function in VSCode shows that it deployed, but I see nothing when I visit my Azure portal. When I remove/comment out the database interaction code, everything seems to work fine. Did someone find a workaround for this? I am using NodeJS btw! @bhagyshricompany

This screenshot from the logs shows that the function was found but it could not be loaded. I have no idea why. image

tjnangosha avatar Apr 01 '24 17:04 tjnangosha

@tostringtheory , I am using Github workflows and have verified the worker.config.json in the pipeline functions artifact, but that already contains "defaultExecutablePath": "dotnet". So, I guess that's not the original reason for my issue...

SamVanhoutte avatar Apr 02 '24 14:04 SamVanhoutte

I have similar issue with NodeJS function. When I deploy to Consumption Plan - everything works well. But if I create "App service plan" (I need Always On feature) function and deploy same code - I cannot see my function in list. Any ideas what could be the reason?

bo44arov avatar Apr 06 '24 19:04 bo44arov

Ok, the reason was I've been creating Azure function resources in Europe North region. Once I've moved to Europe West everything worked for me. That's weird...

bo44arov avatar Apr 07 '24 07:04 bo44arov

Ok, the reason was I've been creating Azure function resources in Europe North region. Once I've moved to Europe West everything worked for me. That's weird...

Use a containerized environment if you can.

kunmii avatar Apr 18 '24 20:04 kunmii

Any feedback on this? Also had this issue but it seems to have fixed on itself

pedrcc17 avatar Apr 23 '24 13:04 pedrcc17