功能上傳檔案到檔案共享
Function UploadFiles
{
Write-Host -ForegroundColor Green "Upload files to file share.."
## Get the storage account context
$ctx=(Get-AzStorageAccount -ResourceGroupName $resourceGroupName -Name
$storageAccName).Context
## Get the file share
$fileShare=Get-AzStorageShare -Context $ctx -Name $fileShareName
## Upload the file
Set-AzStorageFileContent -Share $fileShare -Source $fileName -Path $folderPath -Force
}
這是我得到的錯誤
Set-AzStorageFileContent : Cannot bind parameter 'Share'. Cannot convert the
"Microsoft.WindowsAzure.Commands.Common.Storage.ResourceModel.AzureStorageFileShare" value of
type
"Microsoft.WindowsAzure.Commands.Common.Storage.ResourceModel.AzureStorageFileShare" to type
"Microsoft.Azure.Storage.File.CloudFileShare".
At line:22 char:37
Set-AzStorageFileContent -Share $fileShare -Source $fileName -Pat ...
~~~~~~~~~~
CategoryInfo : InvalidArgument: (:) [Set-AzStorageFileContent],
ParameterBindingException
FullyQualifiedErrorId :
CannotConvertArgumentNoMessage,Microsoft.WindowsAzure.Commands.Storage.File.Cmdlet.SetAzureStorageFileContent
uj5u.com熱心網友回復:
如評論中所述,該錯誤是不言自明的。Get-AzStorageShare回傳一個型別的物件,AzureStorageFileShare而Set-AzStorageFileContent期望-Share型別的引數CloudFileShare(或String)。
解決這個問題的兩種方法:
- 您可以將共享名稱(字串)和背景關系傳遞給
Set-AzStorageFileContent. 就像是:
Set-AzStorageFileContent -Share $fileShareName -Source $fileName -Path $folderPath -Context $ctx -Force
- 使用
CloudFileShare的屬性AzureStorageFileShare。就像是:
Set-AzStorageFileContent -Share $fileShare.CloudFileShare -Source $fileName -Path $folderPath -Force
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/414558.html
標籤:
