gpt4 book ai didi

azure - 二头肌模板 ~ 在 ADLS 中创建目录

转载 作者:行者123 更新时间:2023-12-02 06:35:50 25 4
gpt4 key购买 nike

我正在尝试从带有 azurerm 提供程序的 Terraform 过渡到 Bicep,并且花了很长时间才弄清楚如何使用 Bicep 来填充我所需的 ADLS Gen 2 目录结构。

我的许多构建都需要一个包含大量容器的新 ADLS,然后在每个容器内我需要嵌套目录,有时是三到四层深。在 Terraform 中,使用存储/路径资源类型非常简单:https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_data_lake_gen2_path

我看不到任何使用二头肌的等效项。我缺少什么?实现这一目标似乎远程可行的唯一可能性是打包部署 Powershell 或 CLI 脚本,但这看起来像是为了完成如此琐碎的事情而进行大量额外的配置和工作。

我会为我的二头肌提供代码示例,但它们只会显示存储和容器资源,可能不会很有用。容器资源非常适合创建根目录 - 但我看不到如何让 Bicep 在其中创建目录/路径。请问有人可以帮忙吗?

更新

在二头肌中似乎不可能。很高兴被证明是错误的。

最佳答案

您必须使用部署脚本在 ADLS Gen2 文件系统中创建目录。您可以include inline Azure CLI scripts in Bicep templates 。您可以使用 the Azure CLI command az storage fs directory create 创建目录。如果我们将此命令包含在部署 ADLS Gen 2 存储帐户的 Bicep 模板中,它将如下所示:

param location string = 'westeurope'
param containerName string = 'mycontainer'
param directoryName string = 'mydirectory'

resource storageAccount 'Microsoft.Storage/storageAccounts@2022-09-01' = {
name: uniqueString(resourceGroup().id)
kind: 'StorageV2'
location: location
sku: {
name: 'Standard_LRS'
}
properties: {
isHnsEnabled: true
}

resource container 'blobServices@2022-09-01' = {
name: 'default'

resource container 'containers@2022-09-01' = {
name: containerName
}
}
}

resource createDirectory 'Microsoft.Resources/deploymentScripts@2020-10-01' = {
name: 'createDirectory'
kind: 'AzureCLI'
location: location
properties:{
azCliVersion: '2.42.0'
retentionInterval: 'P1D'
arguments: '\'${storageAccount.name}\' \'${containerName}\' \'${directoryName}\''
scriptContent: 'az storage fs directory create --account-name $1 -f $2 -n $3 --auth-mode key'
environmentVariables: [
{
name: 'AZURE_STORAGE_KEY'
secureValue: storageAccount.listKeys().keys[0].value
}
]
}
}

关于azure - 二头肌模板 ~ 在 ADLS 中创建目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74924291/

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