微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

将文件保存到子目录中的Azure Fileshare

如何解决将文件保存到子目录中的Azure Fileshare

以下是我用来将文件保存到Azure FileShare的Runbook代码。但无法保存在子目录中。

#Set the context using the storage account name and key
$context = New-AzureStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey 


$s = Get-AzureStorageShare "X1" –Context $context


$ErrorLogFileName = "Test.csv" 
$LogItem = New-Item -ItemType File -Name $ErrorLogFileName
      $_ | Out-File -FilePath $ErrorLogFileName -Append


Set-AzureStorageFileContent –Share $s –Source $ErrorLogFileName 

在这里,我具有类似 X1 / X2 文件夹结构。但是无法到达那里并保存Test.csv。实际上可以将其X1文件夹保存在Azure文件共享上。有什么主意吗?

预先感谢

解决方法

您可以为Set-AzureStorageFileContent指定-Path参数。

例如,文件共享为X1,并且X1内有一个文件夹X2。然后,您可以使用以下命令:

Set-AzureStorageFileContent –Share "X1" –Source $ErrorLogFileName -Path "X2" -Context $context

顺便说一句,您使用的命令很旧,请尝试考虑使用最新的az powershell命令。例如,您可以使用Set-AzStorageFileContent代替Set-AzureStorageFileContent(如果尝试使用az模块,请用新命令替换所有旧命令)。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。