Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
SamVanhoutte opened this issue Feb 14, 2024 · 13 comments

Comments

@SamVanhoutte
Copy link

SamVanhoutte commented Feb 14, 2024

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
@bhagyshricompany bhagyshricompany self-assigned this Mar 19, 2024
@bhagyshricompany
Copy link

bhagyshricompany commented Mar 19, 2024

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

@piero2c
Copy link

piero2c commented Mar 19, 2024

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)

@FranckRedeo
Copy link

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.

@tostringtheory
Copy link

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 🤷‍♂️.

@matteomessmer
Copy link

matteomessmer commented Mar 22, 2024

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

@tdysko-cf
Copy link

have the same

@trevor-james-nangosha
Copy link

trevor-james-nangosha commented Apr 1, 2024

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

@SamVanhoutte
Copy link
Author

@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...

@bo44arov
Copy link

bo44arov commented Apr 6, 2024

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
Copy link

bo44arov commented Apr 7, 2024

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...

@kunmii
Copy link

kunmii commented Apr 18, 2024

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.

@pedrcc17
Copy link

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

@mpvoss
Copy link

mpvoss commented Jun 3, 2024

I could not get deploy to work using the Azure/functions-action@v1 github action, but once I added a --build-remote true to the azure cli it finally worked. Pipeline example:

    - name: Deploy azure function
      uses: azure/CLI@v1
      with:
        inlineScript: |
            az functionapp deployment source config-zip -g $AZURE_RESOURCE_GROUP -n $AZURE_FUNCTIONAPP_NAME --src functionapp.zip --build-remote true

Miscellaneous findings from the 7 hours I wasted chasing this

  • The ENABLE_ORYX_BUILD, SCM_DO_BUILD_DURING_DEPLOYMENT, and WEBSITE_RUN_FROM_PACKAGE settings are all important, finicky, and confusing. This write-up helped me way more than the MS Docs. In my terraform I have the first two set to true and I omit the last one (I think it gets set by the remote deploy)
  • You need to be verrrrry careful about the dir structure of your zip. You can go to the "App Files" part of the Azure UI to double check that you've zipped up the supporting files only and not their parent directory. In my pipeline I cd into the test_func below, run zip -r ../functionapp.zip ., then cd back out and use that zip for the deploy command
test_func/
├── function_app.py
├── function.json
├── host.json
├── requirements.txt
└── WrapperFunction
    └── __init__.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests