Why am i getting "New-AzSqlDatabaseImport : Not found: Entity not found to invoke import"

Viewed 358

I have a script to handle some parameters and deploy an arm template with those parameters, and then create a database using a bacpac file in my storage account. When my script is trying to invoke the cmdlet "New-AzSqlDatabaseImport" i'm getting "NotFound: Entity not found to invoke import"

I have trying updating all of my Az modules, and tried to run the cmdlet manually and fill in the parameters manually.

Write-Host "Creating database and importing data"
$bloblink = (Get-AzStorageAccount -ResourceGroupName $ResourceGroup -Name $StorageName).PrimaryEndpoints.Blob
$uri = $bloblink + $containerName + "/" + $bacpacFile
$importRequest = New-AzSqlDatabaseImport `
    -ResourceGroupName $ResourceGroup `
    -ServerName $SQLServer `
    -DatabaseName $database_ql_name `
    -DatabaseMaxSizeBytes $databaseMaxSizeBytes `
    -StorageKeyType "StorageAccessKey" `
    -StorageKey $(Get-AzStorageAccountKey -ResourceGroupName $ResourceGroup -StorageAccountName $StorageName).Value[0] `
    -StorageUri $uri `
    -Edition $DatabaseEdition `
    -ServiceObjectiveName $DatabaseSize `
    -AdministratorLogin $dbUsername `
    -AdministratorLoginPassword $dbPassword

I expect it to start a job on Azure to create the database and start the import job.

This is the error im getting instead (i replaced the full path).

At *PATH*/Deployment.ps1:262 char:18
+ $importRequest = New-AzSqlDatabaseImport `
+                  ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [New-AzSqlDatabaseImport], CloudException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Sql.ImportExport.Cmdlet.NewAzureSqlDatabaseImport
1 Answers

I just encountered the same error. I found that the -ServerName argument is case-sensitive. So check your $SQLServer-variable.

Related