Deploying existing python package to Azure function succesfull, but not recognized

84 views Asked by At

Dynatrace offers a default package (in python) which enables forwarding logs from an eventhub to their platform. Here is their documentation about it.

I am using an existing python azure function in which I want to deploy it to using Azure DevOps yaml pipeline.

Write-Host 'Downloading'
wget "${{ parameters.logForwarderPackageUrl }}" -O "log-forwarder.zip"

Write-Host 'Deploying'
az webapp deployment source config-zip `
  --resource-group "${{ parameters.resourceGroup }}" `
  --name "logforwarder-dev" `
  --src "log-forwarder.zip"

The azure function has a configuration setting SCM_DO_BUILD_DURING_DEPLOYMENT set to true.

I also have tried az functionapp deployment... but this sets the SCM_DO_BUILD_DURING_DEPLOYMENT to false for some reason.

The problem is that deployment is successful but somehow the package isn't running. This is the output of the script:

WARNING: Getting scm site credentials for zip deployment
WARNING: Starting zip deployment. This operation can take a while to complete ...
WARNING: Deployment endpoint responded with status code 202

Does anyone know what I have been missing or what I have to check to see why the python script isn't running/deploying?

enter image description here

For what I can tell, all essential files are deployed.

enter image description here

enter image description here

I do not have enough experience with Python to see my issue. Please help.

1

There are 1 answers

0
Andries On

The problem is solved by having the correct runtime configured in the function app.

I previously set the pythonVersion in siteConfig to 3.11 but that didn't work. Now I use linuxFxVersion Python|3.11 which does seem to work.

This is the bicep I am now using.

resource functionApp 'Microsoft.Web/sites@2022-09-01' = {
  name: '${name}-${environmentDTAP}'
  location: location
  kind: 'functionapp'
  properties: {
    httpsOnly: true
    serverFarmId: serverFarmId
    clientAffinityEnabled: true
    siteConfig: {
      use32BitWorkerProcess: use32BitWorkerProcess
      alwaysOn: alwaysOn
      linuxFxVersion: 'Python|3.11'
      appSettings: [
          {
            name: 'AzureWebJobsStorage'
            value: blobStorageConnectionString
          }
          {
            name: 'FUNCTIONS_EXTENSION_VERSION'
            value: '~4'
          }
          {
            name: 'FUNCTIONS_WORKER_RUNTIME'
            value: 'python'
          }
          {
            name: 'APPINSIGHTS_INSTRUMENTATIONKEY'
            value: appInsights.outputs.instrumentationKey
          }
          {
            name: 'DYNATRACE_URL'
            value: dynatraceLogForwarderApiUrl
          }
          {
            name: 'DYNATRACE_ACCESS_KEY'
            value: dynatraceLogForwarderApiKey
          }
          {
            name: 'EVENTHUB_CONNECTION_STRING'
            value: eventHub.outputs.listenConnectionString
          }
          {
            name: 'EVENTHUB_NAME'
            value: eventHub.outputs.eventHubName
          }
          {
            name: 'SCM_DO_BUILD_DURING_DEPLOYMENT'
            value: 'true'
          }
          {
            name: 'REQUIRE_VALID_CERTIFICATE'
            value: 'false'
          }
          {
            name: 'SELF_MONITORING_ENABLED'
            value: 'false'
          }
          {
            name: 'RESOURCE_ID'
            value: '${name}-${environmentDTAP}'
          }
          {
            name: 'REGION'
            value: location
          }
      ]
    }
  }
}