Import Database (classic)

 

Updated: October 5, 2016

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.

This command uses the classic deployment model. You should use the newer Resource Manager based REST API commands located here. For more information, see Azure Resource Manager vs. classic deployment: Understand deployment models and the state of your resources.

The Import Database request must be specified as follows:

  • Replace {subscriptionId} with your subscription ID.

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

MethodRequest URIHTTP Version
POSThttps://management.core.windows.net:8443/{subscriptionId}/services/sqlservers/servers/{serverName}/DacOperations/ImportHTTP/1.1

URI Parameters

None.

Request Headers

The following table describes the required and optional request headers:

Request HeaderDescription
x-ms-versionRequired. Specifies the version of the operation to use for this request. This header should be set to 2012-03-01.
x-ms-client-request-idOptional. 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 NameDescription
AzureEditionThe edition (service tier) to use when creating a database to import into.
ServiceObjectiveThe desired service objective (performance level) of the imported database.
BlobCredentialsThe required information to connect to blob storage to retrieve the BACPAC.
BlobCredentials:URIThe URI of the BACPAC to import.
BlobCredentials:StorageAccessKeyThe primary access key for accessing storage.
ConnectionInfoThe information for connecting to the Azure SQL Database.
ConnectionInfo:DatabaseNameThe name to use for the imported database.
ConnectionInfo:PasswordThe password for connecting to the Azure SQL Database Server that the database will be imported into.
ConnectionInfo:ServerNameThe name of the server into which the database will be imported. This must be the fully qualified domain name of the server.
ConnectionInfo:UserNameThe user name to connect to the Azure SQL Database Server.
DatabaseSizeInGBThe maximum size of the imported Database in Gigabytes.

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 HeaderDescription
x-ms-request-idA 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=”http://schemas.microsoft.com/2003/10/Serialization/”>00000000-0000-0000-0001-000000000001</guid>  

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

Show: