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

时间:2020-10-23 11:25:42

标签: azure azure-devops azure-pipelines azure-files azure-runbook

以下是我用来将文件保存到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文件共享上。有什么主意吗?

预先感谢

1 个答案:

答案 0 :(得分:0)

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

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

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

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