azure-resource-manager - How do I deploy file share within storage account using ARM template
问题描述
I can successfully create a storage account using an ARM template and I realize the ARM template does not directly support creating a file share on the storage account via any of the existing providers. I thought I would write a PowerShell script and use the custom script extension in the arm template but it seems like that can only run on a VM (typically used for post setup stuff on VM).
Is there a way to create the file share and child directory structure in PowerShell and have this executed after my ARM template is deployed?
解决方案
您可以使用以下 powershell:
创建共享
$storageAcct = Get-AzStorageAccount -ResourceGroupName xxx -Name yyy
New-AzStorageShare `
-Name myshare `
-Context $storageAcct.Context
创建文件夹。
New-AzStorageDirectory `
-Context $storageAcct.Context `
-ShareName "myshare" `
-Path "myDirectory"
上传文件。
# this expression will put the current date and time into a new file on your scratch drive
Get-Date | Out-File -FilePath "C:\Users\ContainerAdministrator\CloudDrive\SampleUpload.txt" -Force
# this expression will upload that newly created file to your Azure file share
Set-AzStorageFileContent `
-Context $storageAcct.Context `
-ShareName "myshare" `
-Source "C:\Users\ContainerAdministrator\CloudDrive\SampleUpload.txt" `
-Path "myDirectory\SampleUpload.txt"
来源:https ://docs.microsoft.com/en-us/azure/storage/files/storage-how-to-use-files-powershell
推荐阅读
- julia - 推入朱莉娅的意外行为
- token - 我需要帮助来构建具有 Solidity 5.0 或更高版本的 ERC-721 合同
- c# - 如何在 C# 中将数据写入 android 文件?
- firebase - Is it possible to mock an authenticated Firebase user, in order to run full testing with jest, while preserving the database rules?
- sql - Custom ordering before regular ordering?
- c# - 在随机猜谜游戏中反击
- algorithm - 如何找到工作之间的最大差距
- javascript - 如何在更改 window.checkoutConfig 数据时调用函数以刷新结帐页面 Magento 2 的内容
- sass - 在 SCSS 中使用函数和 if 语句
- css - Wagtail new installation : CSS not working