gpt4 book ai didi

azure - 如何使用 ARM 模板将文件从主存储库上传到文件共享?

转载 作者:行者123 更新时间:2023-12-03 06:55:08 25 4
gpt4 key购买 nike

我有一个用于创建存储帐户和文件共享的模板。像这样:

{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.5.6.12127",
"templateHash": "3186185032530874094"
}
},
"parameters": {
"storageAccountName": {
"type": "string",
"defaultValue": "[format('storage{0}', uniqueString(resourceGroup().id))]",
"metadata": {
"description": "Specifies the name of the Azure Storage account."
}
},
"fileShareName": {
"type": "string",
"maxLength": 63,
"minLength": 3,
"metadata": {
"description": "Specifies the name of the File Share. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only."
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Specifies the location in which the Azure Storage resources should be deployed."
}
}
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2021-04-01",
"name": "[parameters('storageAccountName')]",
"location": "[parameters('location')]",
"kind": "StorageV2",
"sku": {
"name": "Standard_LRS"
},
"properties": {
"accessTier": "Hot",
"minimumTlsVersion" : "TLS1_2",
"supportsHttpsTrafficOnly": "true"
}
},
{
"type": "Microsoft.Storage/storageAccounts/fileServices/shares",
"apiVersion": "2021-04-01",
"name": "[format('{0}/default/{1}', parameters('storageAccountName'), parameters('fileShareName'))]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]"
]
}
]
}

最佳答案

在 YAML 管道中,您正在使用 AzureFileCopy@4 任务。

#[error]Upload to container: 'fsndevinternetsuite' in storage account: 'strdevinternetsuite' with blob prefix: '' failed with error: 'AzCopy.exe exited with non-zero exit code while uploading files to blob storage.'

从错误消息来看,导致此问题的原因可能是服务连接创建的服务主体没有足够的权限将文件复制到 Azure 存储帐户。

请参阅以下步骤查找服务主体并将存储 Blob 数据所有者和存储 Blob 数据贡献者添加到服务主体。

第 1 步:导航到 Azure 门户 -> AAD -> 应用注册以查找相关的服务主体。

第 2 步:导航到存储帐户并将存储 Blob 数据所有者和存储 Blob 数据贡献者授予服务主体。

更详细的步骤,可以引用这个文档:Assign an Azure role for access to blob data

或者您可以更改为使用 AzureFileCopy@3 来替换 AzureFileCopy@4。您可以检查一下是否可以工作。

关于azure - 如何使用 ARM 模板将文件从主存储库上传到文件共享?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73066582/

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