When attempting to deploy databases to Azure SQL using PowerShell with the New-AzSqlDatabaseImport command I am receiving the following error:
New-AzSqlDatabaseImport : An unexpected error occured while processing the request. Tracking ID: 'mytrackingid'
At C:\mydir\mypowershell.ps1:363 char:18
+ ... rtRequest = New-AzSqlDatabaseImport -ResourceGroupName "myresource ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzSqlDatabaseImport], CloudException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Sql.ImportExport.Cmdlet.NewAzureSqlDatabaseImport
Get-AzSqlDatabaseImportExportStatus : Cannot bind argument to parameter 'OperationStatusLink' because it is null.
At C:\mydir\mypowershell.ps1:376 char:74
+ ... tExportStatus -OperationStatusLink $importRequest.OperationStatusLink
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-AzSqlDatabaseImportExportStatus], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.Azure.Commands.Sql.ImportExport.Cmdlet.GetAzureSqlDatabaseImportExportStatus
What is odd is that I have run this script over a 100 times on other VMs and am wondering if something has changed or is off in this VM being able to grab the desired bacpac file from blob storage.
I have already checked the Lifecycle of the blob storage and there is nothing listed on that page. The blob and containers exist.
I have installed the Az and SQLServer modules and am able to connect to Azure using the Connect-AzAccount followed by setting my desired subscription by Set-AzContext -SubscriptionId
I have checked the NSGs and am able to open web pages from a browser on the VM I am running the following PowerShell from:
$importRequest = New-AzSqlDatabaseImport -ResourceGroupName "myresourcegroup" `
-ServerName "5878956-sql" `
-DatabaseName "mydatabase"`
-DatabaseMaxSizeBytes "262144000" `
-StorageKeyType "StorageAccessKey" `
-StorageKey "mylongaccesskey" `
-StorageUri "https://myblobs.blob.core.windows.net/mycontainer/mydatabase.bacpac" `
-Edition "Standard" `
-ServiceObjectiveName "S1" `
-AdministratorLogin "azuresqladmin" `
-AdministratorLoginPassword $(ConvertTo-SecureString -String "mypassword" -AsPlainText -Force)
# Check import status and wait for the import to complete
$importStatus = Get-AzSqlDatabaseImportExportStatus -OperationStatusLink $importRequest.OperationStatusLink
[Console]::Write("Importing mydatabase")
while ($importStatus.Status -eq "InProgress")
{
$importStatus = Get-AzSqlDatabaseImportExportStatus -OperationStatusLink $importRequest.OperationStatusLink
[Console]::Write(".")
Start-Sleep -s 10
}
[Console]::WriteLine("")
$importStatus
Update 1:
Testing today, I am able to import a database through the Azure Portal GUI but PowerShell does not work. I am able to download the blob/bacpac files via PowerShell but the importing with the New-AzSqlDatabaseImport is still failing.
In checking the Azure Portal Activity Log it is showing the following error, so we believe it is communicating with Azure SQL:
"subStatus": {
"value": "InternalServerError",
"localizedValue": "Internal Server Error (HTTP Status Code: 500)"
},