将现有的python包部署到Azure功能成功,但无法识别

问题描述 投票:0回答:1

Dynatrace 提供了一个默认包(Python 语言),可以将日志从 eventhub 转发到其平台。 这是他们的相关文档。

我正在使用现有的 python azure 函数,我想使用 Azure DevOps yaml 管道将其部署到其中。

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"

azure 功能的配置设置

SCM_DO_BUILD_DURING_DEPLOYMENT
设置为
true

我也尝试过

az functionapp deployment...
,但由于某种原因,这将
SCM_DO_BUILD_DURING_DEPLOYMENT
设置为
false

问题在于部署成功,但不知何故该包未运行。 这是脚本的输出:

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

有谁知道我缺少什么或者我必须检查什么才能查看为什么 python 脚本没有运行/部署?

据我所知,所有必要的文件都已部署。

我没有足够的 Python 经验来查看我的问题。请帮忙。

python azure azure-functions azure-cli dynatrace
1个回答
0
投票

通过在函数应用程序中配置正确的运行时可以解决问题。

我之前将 siteConfig 中的

pythonVersion
设置为
3.11
但这不起作用。 现在我使用
linuxFxVersion
Python|3.11
这似乎确实有效。

这是我现在使用的二头肌。

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
          }
      }
    }
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.