簡體   English   中英

如何將dumb文件導入mySQL Server上的Azure DB,轉儲駐留在blob中。 如何動態訪問blob文件

[英]How to import a dumb file to Azure DB on mySQL Server, the dump resides in the blob. How can I dynamically access the blob file

我的power shell代碼,將轉儲文件從azure存儲下載到我的本地驅動器。 Get-AzureStorageBlobContent -Container $storagecontainername -Blob $backupfilename -Destination $restorefilename

使用本地驅動器中的轉儲文件進行導入。 get-content $restorefilename | &"$mysqlpath" -h $servername -u $username -p $password $database

我希望直接用blob文件替換這個$restorefilename

沒有內置的cmdlet。

您可以在powershell中使用一些.net方法直接將blob文件下載為字符串。

注意:如果blob存儲是公共的,您可以直接使用它的url。 如果blob存儲是私有的,則應為blob生成SAS令牌。

公共blob的示例代碼如下:

$client = New-Object System.Net.WebClient
$client.DownloadString("https://xxx.blob.core.windows.net/f22/t1.txt")

測試結果如下:

在此輸入圖像描述

所以在你的情況下,你可以寫下面的東西:

$client = New-Object System.Net.WebClient
$restorefilename = $client.DownloadString("https://xxx.blob.core.windows.net/f22/t1.txt")
$restorefilename | &"$mysqlpath" -h $servername -u $username -p $password $database

如果您的blob是私有的,您可以按照下面的屏幕截圖生成一個用於下載的sas URL:

在此輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM