New-AzSqlDatabaseImport Cannot bind argument to parameter 'OperationStatusLink' because it is null

Viewed 778

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)"
},
2 Answers

After speaking with Microsoft, I needed to adjust the max bytes to match the Standard Edition max of 250GB I was attempting to deploy to. While a lesser value worked in the past, adjusting this worked.

I changed this:

-DatabaseMaxSizeBytes "262144000"

to this:

-DatabaseMaxSizeBytes "268435456000"

@Kode. Pointed me in the right direction. Valid numbers are

Maximum Size    Maximum Size    Available 
(in bytes)      (in GB)         (edition)
104857600       0.1             Premium, Standard, Basic
524288000       0.5             Premium, Standard, Basic
1073741824      1               Premium, Standard, Basic
2147483648      2               Premium, Standard, Basic
5368709120      5               Premium, Standard
10737418240     10              Premium, Standard
21474836480     20              Premium, Standard
32212254720     30              Premium, Standard
42949672960     40              Premium, Standard
53687091200     50              Premium, Standard
107374182400    100             Premium, Standard
161061273600    150             Premium, Standard
214748364800    200             Premium, Standard
268435456000    250             Premium, Standard
322122547200    300             Premium
429496729600    400             Premium
536870912000    500             Premium
Related