Share via


Import Database (classic)

 

THIS TOPIC APPLIES TO: noSQL Server yesAzure SQL DatabaseyesAzure SQL Data Warehouse noParallel Data Warehouse

Imports a BACPAC file to a Microsoft Azure SQL Database.

Important

The recommended REST commands to work with SQL Database are the Resource Manager based Azure SQL Database REST API. While there is no change to SQL Database, be aware that the classic deployment model command in this article is scheduled for deprecation on December 1, 2019. For a table providing links to the specific new commands you should use, see Operations for Azure SQL Databases.

Request

The Import Database request must be specified as follows:

  • Replace {subscriptionId} with your subscription ID.

  • Replace {serverName} with the name of the source server.

Method Request URI HTTP Version
POST https://management.core.windows.net:8443/{subscriptionId}/services/sqlservers/servers/{serverName}/DacOperations/Import HTTP/1.1

URI Parameters

None.

Request Headers

The following table describes the required and optional request headers:

Request Header Description
x-ms-version Required. Specifies the version of the operation to use for this request. This header should be set to 2012-03-01.
x-ms-client-request-id Optional. Provides a client-generated, opaque value with a 1 KB character limit. Using this header is highly recommended for correlating client-side activities with requests received by the server.

Request Body

The format of the request body for a V12 server is as follows:

<ImportInput xmlns="http://schemas.datacontract.org/2004/07/Microsoft.SqlServer.Management.Dac.ServiceTypes" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">  
  <AzureEdition>Standard</AzureEdition>  
  <BlobCredentials i:type="BlobStorageAccessKeyCredentials">  
    <Uri>{uriBase}</Uri>  
    <StorageAccessKey>+Ka1LjBc36Pa62WOCJ9zXJjlN5qU6YU3B2JYTgSfw8xiQKlrBoOmAEcdJSO3/YPA5JcJAmMSWCyQB7w1D96k8A==</StorageAccessKey>  
  </BlobCredentials>  
  <ConnectionInfo>  
    <DatabaseName>{dbName}</DatabaseName>  
    <Password>{myPassword}</Password>  
    <ServerName>{serverName}.database.windows.net</ServerName>  
    <UserName>{mylogin}</UserName>  
  </ConnectionInfo>  
  <DatabaseSizeInGB>1</DatabaseSizeInGB>  
  <ServiceObjective>S1</ServiceObjective>  
</ImportInput>  

The format of the request body for a V11 server is as follows:

<ImportInput xmlns="http://schemas.datacontract.org/2004/07/Microsoft.SqlServer.Management.Dac.ServiceTypes" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">  
  <AzureEdition>Web</AzureEdition>  
  <BlobCredentials i:type="BlobStorageAccessKeyCredentials">  
    <Uri>{uriBase}</Uri>  
    <StorageAccessKey>+Ka1LjBc36Pa62WOCJ9zXJjlN5qU6YU3B2JYTgSfw8xiQKlrBoOmAEcdJSO3/YPA5JcJAmMSWCyQB7w1D96k8A==</StorageAccessKey>  
  </BlobCredentials>  
  <ConnectionInfo>  
    <DatabaseName>{dbName}</DatabaseName>  
    <Password>{myPassword}</Password>  
    <ServerName>{serverName}.database.windows.net</ServerName>  
    <UserName>{mylogin}</UserName>  
  </ConnectionInfo>  
  <DatabaseSizeInGB>1</DatabaseSizeInGB>  
</ImportInput>  

The following table describes the elements of the request body:

Element Name Description
AzureEdition The edition (service tier) to use when creating a database to import into.
ServiceObjective The desired service objective (performance level) of the imported database.
BlobCredentials The required information to connect to blob storage to retrieve the BACPAC.
BlobCredentials:URI The URI of the BACPAC to import.
BlobCredentials:StorageAccessKey The primary access key for accessing storage.
ConnectionInfo The information for connecting to the Azure SQL Database.
ConnectionInfo:DatabaseName The name to use for the imported database.
ConnectionInfo:Password The password for connecting to the Azure SQL Database Server that the database will be imported into.
ConnectionInfo:ServerName The name of the server into which the database will be imported. This must be the fully qualified domain name of the server.
ConnectionInfo:UserName The user name to connect to the Azure SQL Database Server.
DatabaseSizeInGB The maximum size of the imported Database in Gigabytes.

Response

The response includes an HTTP status code, a set of response headers, and a response body.

Status Code

Successful import of the database returns a status of 'OK'.

Response Headers

The response for this operation includes the following headers.

Response Header Description
x-ms-request-id A value that uniquely identifies a request made against the database management service. This request id is used for request tracking. If a failure occurs that requires the user to contact Microsoft Support, the request id should be provided to Microsoft to assist in tracking and resolving the failure for the request.

Response Body

The Guid in the response is the RequestID and can be used to query the service for the status of the operation.

<guid xmlns=”https://schemas.microsoft.com/2003/10/Serialization/”>00000000-0000-0000-0001-000000000001</guid>  

See Also

Common REST API Error Codes
Azure SQL Database
Operations for Azure SQL Databases
Azure SQL Database Cmdlets