首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在部署时将Azure函数运行时版本设置为~1

在部署时将Azure函数运行时版本设置为~1
EN

Stack Overflow用户
提问于 2020-09-02 09:08:00
回答 1查看 174关注 0票数 1

我有一个AzureDevOps管道,它使用以下ARM模板部署Azure函数:

代码语言:javascript
复制
{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "functionAppCSName": {
            "type": "string"
        },
        "storageAccountName": {
            "type": "string"
        },
        "storageAccountType": {
            "type": "string",
            "defaultValue": "Standard_LRS",
            "metadata": {
                "description": "Geo-replication type of Storage account"
            },
            "allowedValues": [
                "Standard_LRS",
                "Standard_GRS",
                "Standard_ZRS",
                "Standard_RGRS"
            ]
        },
        "serverFarmsName": {
            "type": "string"
        },
        "appInsightsName": {
            "type": "string"
        },
        "appinsightResourceGroupName": {
            "type": "string"
        },
        "webURL": {
            "type": "string"
        },
        "vaultName": {
            "type": "string"
        },
        "sspVaultName": {
            "type": "string"
        },
        "marketplaceVaultName": {
            "type": "string"
        },
        "redisRgName": {
            "type": "string"
        },
        "redisName": {
            "type": "string"
        },
        "environment": {
            "type": "string"
        },
        "aadTenant": {
            "type": "string"
        },
        "aadClientId": {
            "type": "string"
        },
        "audience": {
            "type": "string"
        },
        "location": {
            "type": "string"
        }
    },
    "resources": [
        {
            "type": "Microsoft.Storage/storageAccounts",
            "name": "[parameters('storageAccountName')]",
            "location": "[parameters('location')]",
            "apiVersion": "2019-04-01",
            "sku": {
                "name": "[parameters('storageAccountType')]"
            },
            "kind": "StorageV2",
            "properties": {
            }
        },
        {
            "type": "Microsoft.Web/sites",
            "kind": "functionapp",
            "name": "[parameters('functionAppCSName')]",
            "apiVersion": "2016-08-01",
            "location": "[parameters('location')]",
            "dependsOn": [
                "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]"
            ],
            "identity": {
                "type": "SystemAssigned"
            },
            "tags": {
            },
            "properties": {
                "httpsOnly": true,
                "enabled": true,
                "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('serverFarmsName'))]",
                "reserved": false,
                "siteConfig": {
                    "AlwaysOn": true,
                    "ftpsState": "Disabled"
                },
                "clientAffinityEnabled": true,
                "clientCertEnabled": false,
                "hostNamesDisabled": false,
                "containerSize": 1536,
                "dailyMemoryTimeQuota": 0,
                "remoteDebuggingEnabled": false,
                "webSocketsEnabled": false
            },
            "resources": [
                {
                    "apiVersion": "2016-08-01",
                    "name": "appsettings",
                    "type": "config",
                    "dependsOn": [
                        "[resourceId('Microsoft.Web/Sites', parameters('functionAppCSName'))]"
                    ],
                    "properties": {
                        "SSPSYSTEM_KEYVAULT_URI": "[concat('https://',parameters('sspvaultname'),'.vault.azure.net')]",
                        "SSP_KEYVAULT_URI": "[concat('https://',parameters('vaultName'),'.vault.azure.net')]",
                        "MP_KEYVAULT_URI": "[concat('https://',parameters('marketplaceVaultName'),'.vault.azure.net')]",
                        "AzureWebJobsStorage": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storageAccountName'), ';AccountKey=', listKeys(parameters('storageAccountName'),'2019-06-01').keys[0].value)]",
                        "AzureWebJobsDashboard": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storageAccountName'), ';AccountKey=', listKeys(parameters('storageAccountName'),'2019-06-01').keys[0].value)]",
                        "FUNCTIONS_EXTENSION_VERSION": "~3",
                        "AzureWebJobsSecretStorageType": "Files",
                        "APPINSIGHTS_INSTRUMENTATIONKEY": "[reference(resourceId(parameters('appinsightResourceGroupName'),'Microsoft.Insights/components', parameters('appInsightsName')), '2014-04-01').InstrumentationKey]",
                        "CacheConnectionString": "[concat(parameters('redisName'),'.redis.cache.windows.net,abortConnect=false,ssl=true,password=', listKeys(resourceId(parameters('redisRgName'),'Microsoft.Cache/Redis',parameters('redisName')), '2015-08-01').primaryKey)]",
                        "AssetCacheKey": "[parameters('environment')]"
                    }
                },
                {
                    "comments": "CORS allow origins *.",
                    "type": "Microsoft.Web/sites/config",
                    "name": "[concat(parameters('functionAppCSName'), '/web')]",
                    "apiVersion": "2016-08-01",
                    "properties": {
                        "cors": {
                            "allowedOrigins": [
                                "https://functions.azure.com",
                                "https://functions-staging.azure.com",
                                "https://functions-next.azure.com",
                                "[parameters('webURL')]",
                                "http://localhost:4200"
                            ]
                        }
                    },
                    "dependsOn": [
                        "[concat('Microsoft.Web/sites/', parameters('functionAppCSName'))]",
                        "[concat('Microsoft.Storage/storageAccounts/', parameters('storageAccountName'))]"
                    ]
                },
                {
                    "type": "config",
                    "name": "logs",
                    "apiVersion": "2016-08-01",
                    "location": "[parameters('location')]",
                    "dependsOn": [
                        "[concat('Microsoft.Web/sites/', parameters('functionAppCSName'))]",
                        "[concat('Microsoft.Storage/storageAccounts/', parameters('storageAccountName'))]"
                    ],
                    "properties": {
                        "remoteDebuggingEnabled": false,
                        "webSocketsEnabled": false,
                        "applicationLogs": {
                            "fileSystem": {
                                "level": "Off"
                            },
                            "azureTableStorage": {
                                "level": "Off",
                                "sasUrl": null
                            },
                            "azureBlobStorage": {
                                "level": "Verbose",
                                "sasUrl": "url",
                                "retentionInDays": 7
                            },
                            "httpLogs": {
                                "fileSystem": {
                                    "retentionInMb": 365,
                                    "retentionInDays": 365,
                                    "enabled": true
                                },
                                "azureBlobStorage": {
                                    "sasUrl": "url",
                                    "retentionInDays": 365,
                                    "enabled": true
                                }
                            },
                            "failedRequestsTracing": {
                                "enabled": true
                            },
                            "detailedErrorMessages": {
                                "enabled": true
                            }
                        }
                    }
                },
                {
                    "name": "[concat(parameters('functionAppCSName'), '/authsettings')]",
                    "apiVersion": "2016-08-01",
                    "type": "Microsoft.Web/sites/config",
                    "location": "[parameters('location')]",
                    "dependsOn": [
                        "[resourceId('Microsoft.Web/sites', parameters('functionAppCSName'))]"
                    ],
                    "properties": {
                        "enabled": true,
                        "tokenStoreEnabled": true,
                        "defaultProvider": "AzureActiveDirectory",
                        "clientId": "[parameters('aadClientId')]",
                        "issuer": "[concat('https://login.microsoftonline.com/', parameters('aadTenant'))]",
                        "allowedAudiences": [
                            "[parameters('audience')]"
                        ]
                    }
                }
            ]
        }
    ],
    "outputs": {
        "tenantID": {
            "type": "string",
            "value": "[reference(resourceId('Microsoft.Web/sites', parameters('functionAppCSName')),'2020-06-01', 'Full').identity.tenantId]"
        },
        "objectId": {
            "type": "string",
            "value": "[reference(resourceId('Microsoft.Web/sites', parameters('functionAppCSName')),'2020-06-01', 'Full').identity.principalId]"
        }
    }
}

如您所见,通过执行以下操作,我正在设置函数应用程序的运行时版本

代码语言:javascript
复制
...
{
                    "apiVersion": "2016-08-01",
                    "name": "appsettings",
                    "type": "config",
                    "dependsOn": [
                        "[resourceId('Microsoft.Web/Sites', parameters('functionAppCSName'))]"
                    ],
                    "properties": {
                        "SSPSYSTEM_KEYVAULT_URI": "[concat('https://',parameters('sspvaultname'),'.vault.azure.net')]",
                        "SSP_KEYVAULT_URI": "[concat('https://',parameters('vaultName'),'.vault.azure.net')]",
                        "MP_KEYVAULT_URI": "[concat('https://',parameters('marketplaceVaultName'),'.vault.azure.net')]",
                        "AzureWebJobsStorage": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storageAccountName'), ';AccountKey=', listKeys(parameters('storageAccountName'),'2019-06-01').keys[0].value)]",
                        "AzureWebJobsDashboard": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storageAccountName'), ';AccountKey=', listKeys(parameters('storageAccountName'),'2019-06-01').keys[0].value)]",
                        "FUNCTIONS_EXTENSION_VERSION": "~3",
                        "AzureWebJobsSecretStorageType": "Files",
                        "APPINSIGHTS_INSTRUMENTATIONKEY": "[reference(resourceId(parameters('appinsightResourceGroupName'),'Microsoft.Insights/components', parameters('appInsightsName')), '2014-04-01').InstrumentationKey]",
                        "CacheConnectionString": "[concat(parameters('redisName'),'.redis.cache.windows.net,abortConnect=false,ssl=true,password=', listKeys(resourceId(parameters('redisRgName'),'Microsoft.Cache/Redis',parameters('redisName')), '2015-08-01').primaryKey)]",
                        "AssetCacheKey": "[parameters('environment')]"
                    }
                }
...

问题是,当函数被部署时,运行时版本总是设置为1~,而我修复它的唯一方法是删除函数App和重新部署,或者在管道上一次又一次地运行重新部署,直到它变成~3。

这对我们来说是很令人沮丧的,因为我们不能有一个适当的或顺利的部署。

在手臂模板方面,我遗漏了什么吗?

EN

回答 1

Stack Overflow用户

发布于 2020-09-04 15:11:42

尝试将API版本更改为最新版本。这应该在正在创建的所有/site资源上完成。

代码语言:javascript
复制
{
                    "apiVersion": "2020-06-01",
                    "name": "appsettings",
                    "type": "config",
                    "dependsOn": [
                        "[resourceId('Microsoft.Web/Sites', parameters('functionAppCSName'))]"
                    ],

总是可以在Microsoft上看到最新版本

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63702306

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档