我正在尝试使用ARM模板将Azure Function应用程序部署在这个函数中,并使用Azure Blob触发器。
我能够部署函数应用程序,它已经启动并运行,但里面的函数没有被创建。
首先,我创建了一个函数应用程序,并在其中创建一个函数。我将该函数的所有文件复制到blob存储中,并在appsetting中提供 init*.py和function.json**文件
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.10.61.36676",
"templateHash": "2440974564149075183"
}
},
"parameters": {
"functionAppName": {
"type": "string",
"defaultValue": "test-function-name",
"metadata": {
"description": "The name of the Azure Function app."
}
},
"storageAccountType": {
"type": "string",
"defaultValue": "Standard_LRS",
"allowedValues": [
"Standard_LRS",
"Standard_GRS",
"Standard_RAGRS"
],
"metadata": {
"description": "Storage Account type"
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for all resources."
}
},
"appInsightsLocation": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for Application Insights"
}
},
"functionWorkerRuntime": {
"type": "string",
"defaultValue": "python",
"allowedValues": [
"dotnet",
"node",
"python",
"java"
],
"metadata": {
"description": "The language worker runtime to load in the function app."
}
},
"linuxFxVersion": {
"type": "string",
"defaultValue": "python|3.9",
"metadata": {
"description": "Required for Linux app to represent runtime stack in the format of 'runtime|runtimeVersion'. For example: 'python|3.9'"
}
}
},
"variables": {
"hostingPlanName": "[parameters('functionAppName')]",
"applicationInsightsName": "[parameters('functionAppName')]",
"storageAccountName": "[format('{0}azfunctions', uniqueString(resourceGroup().id))]"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2022-05-01",
"name": "[variables('storageAccountName')]",
"location": "[parameters('location')]",
"sku": {
"name": "[parameters('storageAccountType')]"
},
"kind": "Storage"
},
{
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2021-02-01",
"name": "[variables('hostingPlanName')]",
"location": "[parameters('location')]",
"sku": {
"name": "Y1",
"tier": "Dynamic",
"size": "Y1",
"family": "Y"
},
"properties": {
"computeMode": "Dynamic",
"reserved": true
}
},
{
"type": "Microsoft.Insights/components",
"apiVersion": "2020-02-02",
"name": "[variables('applicationInsightsName')]",
"location": "[parameters('appInsightsLocation')]",
"tags": {
"[format('hidden-link:{0}', resourceId('Microsoft.Web/sites', variables('applicationInsightsName')))]": "Resource"
},
"properties": {
"Application_Type": "web"
},
"kind": "web"
},
{
"type": "Microsoft.Web/sites",
"apiVersion": "2022-03-01",
"name": "[parameters('functionAppName')]",
"location": "[parameters('location')]",
"kind": "functionapp,linux",
"properties": {
"reserved": true,
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]",
"siteConfig": {
"linuxFxVersion": "[parameters('linuxFxVersion')]",
"appSettings": [
{
"name": "APPINSIGHTS_INSTRUMENTATIONKEY",
"value": "[reference(resourceId('Microsoft.Insights/components', parameters('functionAppName')), '2015-05-01').InstrumentationKey]"
},
{
"name": "AzureWebJobsStorage",
"value": "[format('DefaultEndpointsProtocol=https;AccountName={0};EndpointSuffix={1};AccountKey={2}', variables('storageAccountName'), environment().suffixes.storage, listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2019-06-01').keys[0].value)]"
},
{
"name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",
"value": "[format('DefaultEndpointsProtocol=https;AccountName={0};EndpointSuffix={1};AccountKey={2}', variables('storageAccountName'), environment().suffixes.storage, listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2019-06-01').keys[0].value)]"
},
{
"name": "WEBSITE_CONTENTSHARE",
"value": "[toLower(parameters('functionAppName'))]"
},
{
"name": "FUNCTIONS_EXTENSION_VERSION",
"value": "~4"
},
{
"name": "FUNCTIONS_WORKER_RUNTIME",
"value": "[parameters('functionWorkerRuntime')]"
},
{
"name": "SCM_DO_BUILD_DURING_DEPLOYMENT",
"value": "true"
}
]
},
"apiDefinition":
{
"value": [
{
"name": "test-trigger-function",
"type": "function",
"properties": {
"script_href": "blob_url/folder/__init__.py",
"script_root_path_href": "blob_url/folder/",
"config_href": "blob_url/folder/function.json",
"config": {},
"language": "python",
"isDisabled": false
}
}
]
}
},
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]",
"[resourceId('Microsoft.Insights/components', variables('applicationInsightsName'))]",
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
]
}
]
}
字符串
我想创建一个函数应用程序,其操作系统为Linux,运行时为Python3.9,并且在该函数中可以从blob存储中获取旧的函数配置和文件。
我可以创建下面所示的功能应用程序。
的数据
现在我想在下面的函数应用程序中创建函数。
我试着遵循文档,但我无法弄清楚如何在函数应用程序中创建函数。
1条答案
按热度按时间pdtvr36n1#
未使用ARM模板在Azure函数App中创建函数:-
在解决您的需求之后,我发现了一种方法,可以在函数App中添加一个函数,使用
"Microsoft.Web/sites/functions"
资源类型,如下所示。字符串
型
x1c 0d1x的数据
的
的
请参考@GyanBlog的文章以了解模板的更详细结构。