0

我正在使用 Invoke-Sqlcmd 从 Azure 存储文件共享中获取 -InputFile。我正在使用 Get-AzureStorageFileContent 从 Azure 存储中获取文件,但出现以下错误。任何帮助或见解表示赞赏。

Get-AzureStorageFileContent :远程服务器返回错误:(404)未找到。HTTP 状态代码:404 - HTTP 错误消息:指定的资源不存在。在行:35 字符:1

下面是 Powershell 脚本:

$ctx = New-AzureStorageContext -StorageAccountName $azureStorageAccount -StorageAccountKey $storageKey
Get-AzureStorageFileContent -ShareName $azureFileShare -Path $azureFilePath -Destination $destination -Context  $ctx 
# Set Connection parameters
$params = @{
    'Database' = $Database
    'ServerInstance' = $ServerInstance
    'Username' = $dbusername
    'Password' = $dbpassword
    'InputFile' = $ctx+'\'+$scriptFile

}

Invoke-Sqlcmd @params
4

1 回答 1

0

我从这个链接中找到了我的问题的答案如何将放置在 azure 文件存储中的 .csv 文件的内容复制到 powershell 变量?

我使用 Get-AzureStorageFileContent 将文件下载到 powershell runbook 中的 $evn:temp 文件夹,然后在 Invoke-Sqlcmd 中使用它。

Get-AzureStorageFileContent -ShareName $azureFileShare -Path $azureFilePath -Destination $env:temp -Context $context

# Set Connection parameters
$params = @{
    'Database' = $Database
    'ServerInstance' = $ServerInstance
    'Username' = $dbusername
    'Password' = $dbpassword
    'InputFile' = $env:temp

}

Invoke-Sqlcmd @params
于 2020-04-20T15:34:45.333 回答