我正在编写用于使用Powershell脚本在Blob存储上进行Azure SQL备份的代码。 当我运行脚本时,脚本正在显示,但是过了一段时间,当我签入Blob容器时,我看不到任何.bacpac(Backup)文件。 当一段时间后我再次尝试运行代码时,它将显示如下错误
,但是一段时间后,当我再次运行代码时,它成功执行,状态将显示为“进行中”。但是当我在blob容器下检查时,将没有文件。 请在下面找到脚本-
$subscriptionId = "*****"
$serverAdmin = '****'
$serverPassword = '****'
$securePassword = ConvertTo-SecureString $serverPassword -AsPlainText -Force
$creds = New-Object System.Management.Automation.PSCredential($serverAdmin, $securePassword)
$DatabaseName ='*****'
$ResourceGroupName='*****'
$ServerName='*****'
# Generate a unique filename for the BACPAC
$bacpacFilename = $DatabaseName + (Get-Date).ToString("yyyyMMddHHmm") + ".bacpac"
# Storage account info for the BACPAC
$BaseStorageUri = "https://*****.blob.core.windows.net/*****"
$BacpacUri = $BaseStorageUri + $bacpacFilename
$StorageKeytype = "StorageAccessKey"
$StorageKey = "*****"
New-AzureRmSqlDatabaseExport -ResourceGroupName $ResourceGroupName -ServerName $ServerName `
-DatabaseName $DatabaseName -StorageKeytype $StorageKeytype -StorageKey $StorageKey -StorageUri $BacpacUri `
-AdministratorLogin $creds.UserName -AdministratorLoginPassword $creds.Password
答案 0 :(得分:0)
为什么这些代码-DatabaseName $DatabaseName -StorageKeytype $StorageKeytype -StorageKey $StorageKey -StorageUri $BacpacUri
是String
?
然后执行New-AzureRmSqlDatabaseExport
肯定会出现错误。您可以看到此文档:New-AzureRmSqlDatabaseExport。
关于另一个错误:
Error encountered during the service operation. Blob https://****.blob.core.windows.net/*** is not writeable. The remote server returned an error: (404) Not Found. The remote server returned an error: (404) Not Found
我认为您可以看到此blob作为参考:Blob is not writeable。此Blob与您一样具有相同的错误:
Error encountered during the service operation. Blob https://XXXXXXXXXX.blob.core.windows.net/XXXXX-container/ABC.bacpacklj1234klj12l3k4jl2k34jl2k3j4lk23j4l12k34jlk23j4lk23lk4j234A8i3t1GAs4Tvx2wjQRf7nTi/fM0+v7o7SWuUTU6WpRwO2SM0w== is not writeable. The remote server returned an error: (404) Not Found. The remote server returned an error: (404) Not Found.
希望这可以为您提供帮助。