gpt4 book ai didi

用于创建函数应用程序的 Azure 二头肌模板出现以下错误 "LinuxFxVersion has an invalid value."

转载 作者:行者123 更新时间:2023-12-02 08:12:23 27 4
gpt4 key购买 nike

我尝试使用 azure 二头肌模板创建 python 函数应用程序,但是出现以下错误:

“LinuxFxVersion 的值无效。”

我使用 linuxFx 版本而不是 python 版本,因为以下文档中使用了它:

https://learn.microsoft.com/en-us/azure/azure-functions/functions-infrastructure-as-code?tabs=bicep#linux-1

Azure 函数二头肌模板

resource appService 'Microsoft.Web/serverfarms@2022-03-01' = {
name: appService
location: location
sku: {
name: 'EP1'
tier: 'ElasticPremium'
family: 'EP'
}
kind: 'elastic'

}

var functionAppName = 'tml-functionapp'

resource functionApp 'Microsoft.Web/sites@2020-06-01' = {
name: 'func-${project}-${role}-${env}'
location: loc
tags: appTagsComb
kind: 'functionapp,linux'
identity: {
type: 'SystemAssigned'
}
properties: {
reserved: true
serverFarmId: appService.id
siteConfig: {

appSettings: [
{
name: 'AzureWebJobsStorage'
value: 'DefaultEndpointsProtocol=https;AccountName=${funcApiStorage.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${listKeys(funcApiStorage.id, funcApiStorage.apiVersion).keys[0].value}'
}
{
name: 'FUNCTIONS_EXTENSION_VERSION'
value: '~4'
}
{
name: 'FUNCTIONS_WORKER_RUNTIME'
value: 'python'
}
{
name: 'WEBSITE_CONTENTSHARE'
value: functionAppName
}
{
name: 'WEBSITE_CONTENTAZUREFILECONNECTIONSTRING'
value: 'DefaultEndpointsProtocol=https;AccountName=${funcApiStorage.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${listKeys(funcApiStorage.id, funcApiStorage.apiVersion).keys[0].value}'

}

{
name: 'APPINSIGHTS_INSTRUMENTATIONKEY'
value: funcappInsights.properties.InstrumentationKey
}

]
linuxFxVersion: 'Python|3.9'
ftpsState: 'Disabled'
minTlsVersion: '1.2'
}
httpsOnly: true

}

最佳答案

您需要包含 pythonVersion 字段也如图所示:

siteConfig: {
pythonVersion: '3.9'
linuxFxVersion: 'python|3.9'
}

经过解决方法后,我尝试使用以下脚本来创建一个 python 函数应用程序,如 Github 中详述。 。 我根据要求相应修改了脚本并能够成功部署:

param  name  string = 'jahnavistoragesceoo'
param location string = 'EastUS'
resource storageAccount 'Microsoft.Storage/storageAccounts@2021-09-01' = {
name: name
location: location
sku: {
name: 'Standard_LRS'
}
kind: 'StorageV2'
}
resource applicationInsights 'Microsoft.Insights/components@2020-02-02' = {
name: 'nameapplication-insights'
location: location
kind: 'web'
properties: {
Application_Type: 'web'
Request_Source: 'rest'
}
}
resource hostingPlan 'Microsoft.Web/serverfarms@2021-03-01' = {
name: name
location: location
kind: 'Linux'
sku: {
name: 'Y1'
tier: 'Dynamic'
}
properties: {
reserved: true
}
}
resource functionApp 'Microsoft.Web/sites@2021-03-01' = {
name: name
location: location
kind: 'functionapp'
identity: {
type: 'SystemAssigned'
}
properties: {
serverFarmId: hostingPlan.id
siteConfig: {
pythonVersion: '3.9'
linuxFxVersion: 'python|3.9'
appSettings: [
{
name: 'AzureWebJobsStorage'
value: 'DefaultEndpointsProtocol=https;AccountName=${storageAccount.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${storageAccount.listKeys().keys[0].value}'
}
{
name: 'SCM_DO_BUILD_DURING_DEPLOYMENT'
value: 'true'
}
{
name: 'ENABLE_ORYX_BUILD'
value: 'true'
}
{
name: 'FUNCTIONS_EXTENSION_VERSION'
value: '~4'
}
{
name: 'APPINSIGHTS_INSTRUMENTATIONKEY'
value: applicationInsights.properties.InstrumentationKey
}
{
name: 'FUNCTIONS_WORKER_RUNTIME'
value: 'python'
}
]
}
httpsOnly: true
}
}

输出:

enter image description here

部署成功并在门户中创建了一个 python 运行时堆栈函数应用:

enter image description here

关于用于创建函数应用程序的 Azure 二头肌模板出现以下错误 "LinuxFxVersion has an invalid value.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75518539/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com