繁体   English   中英

ARM 存储帐户上的文件共享模板

[英]ARM Template for FileShare on Storage Account

我已经使用 Azure 函数等创建了一个存储帐户。设置非常简单 - 我现在将其导出到 ARM 模板。

为了测试它,我从 Azure 中删除了资源,并尝试使用模板来创建东西。

但是,我有这个部分来创建所需的文件共享:

{
    "type": "Microsoft.Storage/storageAccounts/fileServices/shares",
    "apiVersion": "2021-08-01",
    "name": "funcstoretest/default/scale-test1546",
    "dependsOn": [
        "[resourceId('Microsoft.Storage/storageAccounts/fileServices', 'funcstoretest', 'default')]",
        "[resourceId('Microsoft.Storage/storageAccounts', 'funcstoretest')]"
    ],
    "properties": {
        "accessTier": "TransactionOptimized",
        "shareQuota": 5120,
        "enabledProtocols": "SMB"
    }
},

然而,实际使用这个导出的示例总是会导致以下错误:

您的部署中存在错误。

错误代码:部署失败。

##[错误]至少一个资源部署操作失败。 请列出部署操作以获取详细信息。 请参阅https://aka.ms/DeployOperations了解使用详情。

##[错误详情:

##[error]InvalidHeaderValue:HTTP 标头之一的值格式不正确。

现在,删除定义属性的部分(即 accessTier、shareQuota、enabledProtocols)允许部署继续,但导致与 Azure 函数的共享无法使用,抱怨它找不到运行时(并且当我这样做时没有部署函数一个部署)。

关于这应该如何工作的任何想法?

请试试这个。 它工作得很好。

确保传递所需的应用程序设置,因为 function 应用程序将尝试连接到存储帐户,如果未添加,它将面临运行时无法访问的错误。

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "appName": {
      "type": "string",
      "defaultValue": "[concat('fnapp', uniqueString(resourceGroup().id))]",
      "metadata": {
        "description": "The name of the function app that you wish to create."
      }
    },
    "storageAccountType": {
      "type": "string",
      "defaultValue": "Standard_LRS",
      "metadata": {
        "description": "Storage Account type"
      }
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "Location for all resources."
      }
    },
    "runtime": {
      "type": "string",
      "defaultValue": "node",
      "metadata": {
        "description": "The language worker runtime to load in the function app."
      }
    },
    "storageAccountName": {
      "type": "string"
      }
    
  },
  "variables": {
    "functionAppName": "[parameters('appName')]",
    "hostingPlanName": "[parameters('appName')]",
    "functionWorkerRuntime": "[parameters('runtime')]"
  },
  "resources": [
    {
      "type": "Microsoft.Storage/storageAccounts",
      "name": "[parameters('storageAccountName')]",
      "apiVersion": "2019-06-01",
      "location": "[parameters('location')]",
      "kind": "Storage",
      "sku": {
        "name": "[parameters('storageAccountType')]"
      }
    },
    {
      "type": "Microsoft.Web/serverfarms",
      "apiVersion": "2019-08-01",
      "name": "[variables('hostingPlanName')]",
      "location": "[parameters('location')]",
      "sku": {
        "name": "Y1",
        "tier": "Dynamic"
      },
      "properties": {
        "name": "[variables('hostingPlanName')]",
        "computeMode": "Dynamic"
      }
    },
    {
      "apiVersion": "2019-08-01",
      "type": "Microsoft.Web/sites",
      "name": "[variables('functionAppName')]",
      "location": "[parameters('location')]",
      "kind": "functionapp",
      "dependsOn": [
        "[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]",
        "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]"
      ],
      "properties": {
        "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]",
        "siteConfig": {
          "appSettings": [
            {
              "name": "AzureWebJobsStorage",
              "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storageAccountName'), ';EndpointSuffix=', environment().suffixes.storage, ';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), '2019-06-01').keys[0].value)]"
            },
            {
              "name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",
              "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storageAccountName'), ';EndpointSuffix=', environment().suffixes.storage, ';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), '2019-06-01').keys[0].value)]"
            },
            {
              "name": "WEBSITE_CONTENTSHARE",
              "value": "[toLower(variables('functionAppName'))]"
            },
            {
              "name": "FUNCTIONS_EXTENSION_VERSION",
              "value": "~2"
            },
            {
              "name": "WEBSITE_NODE_DEFAULT_VERSION",
              "value": "~10"
            },
            {
              "name": "FUNCTIONS_WORKER_RUNTIME",
              "value": "[variables('functionWorkerRuntime')]"
            }
          ]
        }
      }
    }
   
  ]
}

将以下参数传递给它

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "appName": {
      "metadata": {
        "description": "This Param will set the FA name & hostingPlanName"

      },
      "value": "yourappservicename_FunctionappName"
    },
    "storageAccountName": {
      "metadata": {
        "descrption": "Name of the storage account that will be conected & configured with teh function app"
      },
      "value": "Storage_Account_name"
    }
  }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM