Servers - Import Database

Imports a bacpac into a new database.

POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/import?api-version=2023-08-01

URI Parameters

Name In Required Type Description
resourceGroupName
path True

string

The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.

serverName
path True

string

The name of the server.

subscriptionId
path True

string

The subscription ID that identifies an Azure subscription.

api-version
query True

string

The API version to use for the request.

Request Body

Name Required Type Description
administratorLogin True

string

Administrator login name.

administratorLoginPassword True

string

Administrator login password.

storageKey True

string

Storage key.

storageKeyType True

StorageKeyType

Storage key type.

storageUri True

string

Storage Uri.

authenticationType

string

Authentication type.

databaseName

string

Name of the import database.

edition

string

Edition of the import database.

maxSizeBytes

string

Max size in bytes for the import database.

networkIsolation

NetworkIsolationSettings

Optional resource information to enable network isolation for request.

serviceObjectiveName

string

Service level objective name of the import database.

Responses

Name Type Description
200 OK

ImportExportOperationResult

Successfully imported the database.

202 Accepted

Importing the database is in progress.

Headers

Location: string

Other Status Codes

ErrorResponse

*** Error Responses: ***

  • 400 MissingImportExportInputParameters - Missing ImportExport input parameters.

  • 400 InvalidImportExportInputParameter - The import/export request failed due to an invalid input parameter.

  • 400 PolybaseImportAuthenticationTypeNotSupported - Authentication type parameter is not support for PolybaseImport operation.

  • 400 DatabaseExtensionsInvalidOperationMode - Invalid operationMode parameter for database extension.

  • 400 DatabaseExtensionsInvalidStorageKeyType - The storage key type must by 'StorageAccessKey'.

  • 400 DatabaseExtensionsMissingStorageUri - Storage URI cannot be empty.

  • 400 SQLPasswordSpecifiedWithManagedIdentity - administratorLoginPassword should not be specified if authenticationType is ManagedIdentity.

  • 400 InvalidSqlAuthType - ImportExport operation failed because the sql authentication type is invalid

  • 400 BlobAlreadyExist - ImportExport operation failed because the storage blob is already exists

  • 400 InvalidImportExportOperationResourceLocks - The Import/Export request is invalid due to locks on the Private Link resources.

  • 400 DatabaseInvalidSkuPropertyCombination - The properties of the requested sku are inconsistent. Please check that a valid combination is specified. See https://docs.microsoft.com/en-us/rest/api/sql/capabilities/listbylocation#serviceobjectivecapability for more details.

  • 400 ImportExportJobError - The ImportExport operation has failed.

  • 400 BlockedByOutboundFirewall - The outbound firewall rules blocked the request.

  • 400 InvalidOperationType - Provide a valid operation type.

  • 400 InvalidMaxSizeTierCombination - The specified tier does not support the specified database max size.

  • 400 InvalidTier - The user specified an invalid tier.

  • 400 CannotUseReservedDatabaseName - Cannot use reserved database name in this operation.

  • 400 InvalidImportExportParameter - The Import/Export request failed due to an invalid input parameter.

  • 400 InvalidSku - The user specified an invalid sku.

  • 400 InvalidTierSkuCombination - The specified tier does not support the specified sku.

  • 400 InvalidImportExportStorageCredentials - Import/Export operation failed due to invalid storage credentials

  • 400 InvalidImportExportStorageAuthType - Import/Export operation failed due to invalid storage auth type

  • 400 InvalidImportExportStorageKeyFormat - Import/Export operation failed due to invalid storage key format

  • 400 LongImportExportStorageUri - Import/Export operation failed due to long storage URI

  • 400 LargeExportDatabaseSize - Export operation failed because database is larger than max supported size

  • 400 FeatureDisabledOnSelectedEdition - User attempted to use a feature which is disabled on current database edition.

  • 400 UnSupportedImportExportEdition - ImportExport operation failed because it is targeting a invalid edition

  • 400 InvalidImportExportStorageURI - ImportExport operation failed because storage URI is invalid

  • 404 DatabaseDoesNotExist - User has specified a database name that does not exist on this server instance.

  • 404 ServerNotInSubscription - Specified server does not exist on the specified subscription.

  • 404 ServerNotInSubscriptionResourceGroup - Specified server does not exist in the specified resource group and subscription.

  • 404 ResourceNotFound - Invalid request specifying a non-existent resource.

  • 404 ImportExportOperationIdNotFound - The operation Id for import or export cannot be found.

  • 404 OperationIdNotFound - The operation with Id does not exist.

  • 409 ImportExportOperationInProgress - There is an import or export operation in progress on the database.

  • 409 CannotCancelOperation - The management operation is in a state that cannot be cancelled.

  • 409 OperationCancelled - The operation has been cancelled by user.

  • 409 OperationInterrupted - The operation on the resource could not be completed because it was interrupted by another operation on the same resource.

  • 429 SubscriptionTooManyCreateUpdateRequests - Requests beyond max requests that can be processed by available resources.

  • 429 SubscriptionTooManyRequests - Requests beyond max requests that can be processed by available resources.

  • 500 OperationTimedOut - The operation timed out and automatically rolled back. Please retry the operation.

  • 503 TooManyRequests - Requests beyond max requests that can be processed by available resources.

Examples

Imports to a new database, using private link for the SQL server and storage account.
Imports to a new database.

Sample request

POST https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/import?api-version=2023-08-01

{
  "databaseName": "testdb",
  "storageKeyType": "StorageAccessKey",
  "storageKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==",
  "storageUri": "https://test.blob.core.windows.net/test.bacpac",
  "administratorLogin": "login",
  "administratorLoginPassword": "password",
  "authenticationType": "Sql",
  "networkIsolation": {
    "sqlServerResourceId": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr",
    "storageAccountResourceId": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Storage/storageAccounts/test-privatelink"
  }
}

Sample response

{
  "properties": {
    "requestId": "9d9a794a-5cec-4f23-af70-d29511b522a4",
    "requestType": "Import",
    "queuedTime": "2/2/2020 8:33:27 PM",
    "lastModifiedTime": "2/2/2020 8:34:47 PM",
    "blobUri": "https://test.blob.core.windows.net/test.bacpac",
    "serverName": "testsvr.database.windows.net",
    "databaseName": "testdb",
    "status": "Completed"
  },
  "id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb/importExportOperationResults/9d9a794a-5cec-4f23-af70-d29511b522a4",
  "name": "9d9a794a-5cec-4f23-af70-d29511b522a4",
  "type": "Microsoft.Sql/servers/databases/importExportOperationResults"
}
Location: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Sql/locations/japaneast/importExportOperationResults/00000000-0000-0000-0000-000000000000?api-version=2022-08-01

Imports to a new database.

Sample request

POST https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/import?api-version=2023-08-01

{
  "databaseName": "testdb",
  "storageKeyType": "StorageAccessKey",
  "storageKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==",
  "storageUri": "https://test.blob.core.windows.net/test.bacpac",
  "administratorLogin": "login",
  "administratorLoginPassword": "password",
  "authenticationType": "Sql"
}

Sample response

{
  "properties": {
    "requestId": "9d9a794a-5cec-4f23-af70-d29511b522a4",
    "requestType": "Import",
    "queuedTime": "2/2/2020 8:33:27 PM",
    "lastModifiedTime": "2/2/2020 8:34:47 PM",
    "blobUri": "https://test.blob.core.windows.net/test.bacpac",
    "serverName": "testsvr.database.windows.net",
    "databaseName": "testdb",
    "status": "Completed"
  },
  "id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb/importExportOperationResults/9d9a794a-5cec-4f23-af70-d29511b522a4",
  "name": "9d9a794a-5cec-4f23-af70-d29511b522a4",
  "type": "Microsoft.Sql/servers/databases/importExportOperationResults"
}
Location: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Sql/locations/japaneast/importExportOperationResults/00000000-0000-0000-0000-000000000000?api-version=2022-08-01

Definitions

Name Description
ErrorAdditionalInfo

The resource management error additional info.

ErrorDetail

The error detail.

ErrorResponse

Error response

ImportExportOperationResult

An ImportExport operation result resource.

ImportNewDatabaseDefinition

Contains the information necessary to perform import operation for new database.

NetworkIsolationSettings

Contains the ARM resources for which to create private endpoint connection.

PrivateEndpointConnectionRequestStatus

Contains the private endpoint connection requests status.

StorageKeyType

Storage key type.

ErrorAdditionalInfo

The resource management error additional info.

Name Type Description
info

object

The additional info.

type

string

The additional info type.

ErrorDetail

The error detail.

Name Type Description
additionalInfo

ErrorAdditionalInfo[]

The error additional info.

code

string

The error code.

details

ErrorDetail[]

The error details.

message

string

The error message.

target

string

The error target.

ErrorResponse

Error response

Name Type Description
error

ErrorDetail

The error object.

ImportExportOperationResult

An ImportExport operation result resource.

Name Type Description
id

string

Resource ID.

name

string

Resource name.

properties.blobUri

string

Blob Uri.

properties.databaseName

string

Database name.

properties.errorMessage

string

Error message.

properties.lastModifiedTime

string

Last modified time.

properties.privateEndpointConnections

PrivateEndpointConnectionRequestStatus[]

Gets the status of private endpoints associated with this request.

properties.queuedTime

string

Queued time.

properties.requestId

string (uuid)

Request Id.

properties.requestType

string

Request type.

properties.serverName

string

Server name.

properties.status

string

Operation status.

type

string

Resource type.

ImportNewDatabaseDefinition

Contains the information necessary to perform import operation for new database.

Name Type Description
administratorLogin

string

Administrator login name.

administratorLoginPassword

string

Administrator login password.

authenticationType

string

Authentication type.

databaseName

string

Name of the import database.

edition

string

Edition of the import database.

maxSizeBytes

string

Max size in bytes for the import database.

networkIsolation

NetworkIsolationSettings

Optional resource information to enable network isolation for request.

serviceObjectiveName

string

Service level objective name of the import database.

storageKey

string

Storage key.

storageKeyType

StorageKeyType

Storage key type.

storageUri

string

Storage Uri.

NetworkIsolationSettings

Contains the ARM resources for which to create private endpoint connection.

Name Type Description
sqlServerResourceId

string (arm-id)

The resource id for the SQL server which is the target of this request. If set, private endpoint connection will be created for the SQL server. Must match server which is target of the operation.

storageAccountResourceId

string (arm-id)

The resource id for the storage account used to store BACPAC file. If set, private endpoint connection will be created for the storage account. Must match storage account used for StorageUri parameter.

PrivateEndpointConnectionRequestStatus

Contains the private endpoint connection requests status.

Name Type Description
privateEndpointConnectionName

string

The connection name for the private endpoint.

privateLinkServiceId

string

Resource id for which the private endpoint is created.

status

string

Status of this private endpoint connection.

StorageKeyType

Storage key type.

Value Description
SharedAccessKey
StorageAccessKey