Perform a database extension operation, like database import, database export, or polybase import
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extensions/{extensionName}?api-version=2025-01-01
URI Parameters
| Name |
In |
Required |
Type |
Description |
|
databaseName
|
path |
True
|
string
|
The name of the database.
|
|
extensionName
|
path |
True
|
string
|
|
|
resourceGroupName
|
path |
True
|
string
minLength: 1 maxLength: 90
|
The name of the resource group. The name is case insensitive.
|
|
serverName
|
path |
True
|
string
|
The name of the server.
|
|
subscriptionId
|
path |
True
|
string
(uuid)
|
The ID of the target subscription. The value must be an UUID.
|
|
api-version
|
query |
True
|
string
minLength: 1
|
The API version to use for this operation.
|
Request Body
| Name |
Required |
Type |
Description |
|
properties.operationMode
|
True
|
OperationMode
|
Operation mode of the operation: Import, Export, or PolybaseImport.
|
|
properties.storageKey
|
True
|
string
|
Storage key for the storage account. If StorageKeyType is ManagedIdentity, this field should specify the Managed Identity's resource ID.
|
|
properties.storageKeyType
|
True
|
StorageKeyType
|
Storage key type: StorageAccessKey, SharedAccessKey or ManagedIdentity.
|
|
properties.storageUri
|
True
|
string
|
Storage Uri for the storage account.
|
|
properties.administratorLogin
|
|
string
|
Administrator login name. If AuthenticationType is ManagedIdentity, this field should specify the Managed Identity's resource ID.
|
|
properties.administratorLoginPassword
|
|
string
(password)
|
Administrator login password. If AuthenticationType is ManagedIdentity, this field should not be specified.
|
|
properties.authenticationType
|
|
string
|
Authentication type used to access the SQL: Sql, ADPassword or ManagedIdentity.
|
|
properties.databaseEdition
|
|
string
|
Database edition for the newly created database in the case of an import operation.
|
|
properties.maxSizeBytes
|
|
string
|
Database max size in bytes for the newly created database in the case of an import operation.
|
|
properties.networkIsolation
|
|
NetworkIsolationSettings
|
Optional resource information to enable network isolation for request.
|
|
properties.serviceObjectiveName
|
|
string
|
Database service level objective for the newly created database in the case of an import operation.
|
Responses
| Name |
Type |
Description |
|
200 OK
|
ImportExportExtensionsOperationResult
|
Resource 'ImportExportExtensionsOperationResult' update operation succeeded
|
|
202 Accepted
|
|
Resource operation accepted.
Headers
- Location: string
- Retry-After: integer
|
|
Other Status Codes
|
ErrorResponse
|
An unexpected error response.
|
Security
azure_auth
Azure Active Directory OAuth2 Flow.
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
| Name |
Description |
|
user_impersonation
|
impersonate your user account
|
Examples
Create or Update database extensions.
Sample request
PUT https://management.azure.com/subscriptions/a1c0814d-3c18-4e1e-a247-c128c12b1677/resourceGroups/rg_20cbe0f0-c2d9-4522-9177-5469aad53029/providers/Microsoft.Sql/servers/srv_1ffd1cf8-9951-47fb-807d-a9c384763849/databases/878e303f-1ea0-4f17-aa3d-a22ac5e9da08/extensions/polybaseimport?api-version=2025-01-01
{
"properties": {
"operationMode": "PolybaseImport",
"storageKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"storageKeyType": "StorageAccessKey",
"storageUri": "https://teststorage.blob.core.windows.net/testcontainer/Manifest.xml"
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python create_or_update_database_extensions.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = SqlManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.database_extensions.begin_create_or_update(
resource_group_name="rg_20cbe0f0-c2d9-4522-9177-5469aad53029",
server_name="srv_1ffd1cf8-9951-47fb-807d-a9c384763849",
database_name="878e303f-1ea0-4f17-aa3d-a22ac5e9da08",
extension_name="polybaseimport",
parameters={
"properties": {
"operationMode": "PolybaseImport",
"storageKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"storageKeyType": "StorageAccessKey",
"storageUri": "https://teststorage.blob.core.windows.net/testcontainer/Manifest.xml",
}
},
).result()
print(response)
# x-ms-original-file: 2025-01-01/CreateOrUpdateDatabaseExtensions.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { SqlManagementClient } = require("@azure/arm-sql");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to perform a database extension operation, like database import, database export, or polybase import
*
* @summary perform a database extension operation, like database import, database export, or polybase import
* x-ms-original-file: 2025-01-01/CreateOrUpdateDatabaseExtensions.json
*/
async function createOrUpdateDatabaseExtensions() {
const credential = new DefaultAzureCredential();
const subscriptionId = "a1c0814d-3c18-4e1e-a247-c128c12b1677";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.databaseExtensionsOperations.createOrUpdate(
"rg_20cbe0f0-c2d9-4522-9177-5469aad53029",
"srv_1ffd1cf8-9951-47fb-807d-a9c384763849",
"878e303f-1ea0-4f17-aa3d-a22ac5e9da08",
"polybaseimport",
{
operationMode: "PolybaseImport",
storageKey:
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
storageKeyType: "StorageAccessKey",
storageUri: "https://teststorage.blob.core.windows.net/testcontainer/Manifest.xml",
},
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.Sql.Models;
using Azure.ResourceManager.Sql;
// Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/SQL/stable/2025-01-01/examples/CreateOrUpdateDatabaseExtensions.json
// this example is just showing the usage of "DatabaseExtensions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this SqlDatabaseResource created on azure
// for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource
string subscriptionId = "a1c0814d-3c18-4e1e-a247-c128c12b1677";
string resourceGroupName = "rg_20cbe0f0-c2d9-4522-9177-5469aad53029";
string serverName = "srv_1ffd1cf8-9951-47fb-807d-a9c384763849";
string databaseName = "878e303f-1ea0-4f17-aa3d-a22ac5e9da08";
ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName);
SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId);
// invoke the operation
string extensionName = "polybaseimport";
SqlDatabaseExtension sqlDatabaseExtension = new SqlDatabaseExtension
{
OperationMode = DatabaseExtensionOperationMode.PolybaseImport,
StorageKeyType = StorageKeyType.StorageAccessKey,
StorageKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
StorageUri = new Uri("https://teststorage.blob.core.windows.net/testcontainer/Manifest.xml"),
};
ArmOperation<ImportExportExtensionsOperationResult> lro = await sqlDatabase.CreateOrUpdateDatabaseExtensionAsync(WaitUntil.Completed, extensionName, sqlDatabaseExtension);
ImportExportExtensionsOperationResult result = lro.Value;
Console.WriteLine($"Succeeded: {result}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"name": "polybaseimport",
"type": "Microsoft.Sql/servers/databases/extensions",
"id": "/subscriptions/a1c0814d-3c18-4e1e-a247-c128c12b1677/resourceGroups/rg_20cbe0f0-c2d9-4522-9177-5469aad53029/providers/Microsoft.Sql/servers/srv_1ffd1cf8-9951-47fb-807d-a9c384763849/databases/878e303f-1ea0-4f17-aa3d-a22ac5e9da08/extensions/polybaseimport",
"properties": {
"databaseName": "878e303f-1ea0-4f17-aa3d-a22ac5e9da08",
"lastModifiedTime": "lastModifiedTime",
"requestId": "10000000-0000-0000-0000-000000000002",
"requestType": "PolybaseImport",
"serverName": "srv_1ffd1cf8-9951-47fb-807d-a9c384763849",
"status": "succeeded"
}
}
Export database using database extension with Managed Identity.
Sample request
PUT https://management.azure.com/subscriptions/0ca8cd24-0b47-4ad5-bc7e-d70e35c44adf/resourceGroups/rg_d1ef9eae-044d-4710-ba59-b82e84ad3157/providers/Microsoft.Sql/servers/srv_9243d320-ac4e-4f97-8e06-b1167dae5f4c/databases/db_7fe424c8-23cf-4ac3-bdc3-e21f424bdb68/extensions/Export?api-version=2025-01-01
{
"properties": {
"administratorLogin": "/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/rgName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityName",
"authenticationType": "ManagedIdentity",
"operationMode": "Export",
"storageKey": "/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/rgName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityName",
"storageKeyType": "ManagedIdentity",
"storageUri": "https://teststorage.blob.core.windows.net/testcontainer/Manifest.xml"
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python export_database_using_database_extensions_with_managed_identity.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = SqlManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.database_extensions.begin_create_or_update(
resource_group_name="rg_d1ef9eae-044d-4710-ba59-b82e84ad3157",
server_name="srv_9243d320-ac4e-4f97-8e06-b1167dae5f4c",
database_name="db_7fe424c8-23cf-4ac3-bdc3-e21f424bdb68",
extension_name="Export",
parameters={
"properties": {
"administratorLogin": "/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/rgName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityName",
"authenticationType": "ManagedIdentity",
"operationMode": "Export",
"storageKey": "/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/rgName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityName",
"storageKeyType": "ManagedIdentity",
"storageUri": "https://teststorage.blob.core.windows.net/testcontainer/Manifest.xml",
}
},
).result()
print(response)
# x-ms-original-file: 2025-01-01/ExportDatabaseUsingDatabaseExtensionsWithManagedIdentity.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { SqlManagementClient } = require("@azure/arm-sql");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to perform a database extension operation, like database import, database export, or polybase import
*
* @summary perform a database extension operation, like database import, database export, or polybase import
* x-ms-original-file: 2025-01-01/ExportDatabaseUsingDatabaseExtensionsWithManagedIdentity.json
*/
async function exportDatabaseUsingDatabaseExtensionWithManagedIdentity() {
const credential = new DefaultAzureCredential();
const subscriptionId = "0ca8cd24-0b47-4ad5-bc7e-d70e35c44adf";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.databaseExtensionsOperations.createOrUpdate(
"rg_d1ef9eae-044d-4710-ba59-b82e84ad3157",
"srv_9243d320-ac4e-4f97-8e06-b1167dae5f4c",
"db_7fe424c8-23cf-4ac3-bdc3-e21f424bdb68",
"Export",
{
administratorLogin:
"/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/rgName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityName",
authenticationType: "ManagedIdentity",
operationMode: "Export",
storageKey:
"/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/rgName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityName",
storageKeyType: "ManagedIdentity",
storageUri: "https://teststorage.blob.core.windows.net/testcontainer/Manifest.xml",
},
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.Sql.Models;
using Azure.ResourceManager.Sql;
// Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/SQL/stable/2025-01-01/examples/ExportDatabaseUsingDatabaseExtensionsWithManagedIdentity.json
// this example is just showing the usage of "DatabaseExtensions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this SqlDatabaseResource created on azure
// for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource
string subscriptionId = "0ca8cd24-0b47-4ad5-bc7e-d70e35c44adf";
string resourceGroupName = "rg_d1ef9eae-044d-4710-ba59-b82e84ad3157";
string serverName = "srv_9243d320-ac4e-4f97-8e06-b1167dae5f4c";
string databaseName = "db_7fe424c8-23cf-4ac3-bdc3-e21f424bdb68";
ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName);
SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId);
// invoke the operation
string extensionName = "Export";
SqlDatabaseExtension sqlDatabaseExtension = new SqlDatabaseExtension
{
OperationMode = DatabaseExtensionOperationMode.Export,
StorageKeyType = StorageKeyType.ManagedIdentity,
StorageKey = "/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/rgName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityName",
StorageUri = new Uri("https://teststorage.blob.core.windows.net/testcontainer/Manifest.xml"),
AdministratorLogin = "/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/rgName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityName",
AuthenticationType = "ManagedIdentity",
};
ArmOperation<ImportExportExtensionsOperationResult> lro = await sqlDatabase.CreateOrUpdateDatabaseExtensionAsync(WaitUntil.Completed, extensionName, sqlDatabaseExtension);
ImportExportExtensionsOperationResult result = lro.Value;
Console.WriteLine($"Succeeded: {result}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"name": "Export",
"type": "Microsoft.Sql/servers/databases/extensions",
"id": "/subscriptions/0ca8cd24-0b47-4ad5-bc7e-d70e35c44adf/resourceGroups/rg_d1ef9eae-044d-4710-ba59-b82e84ad3157/providers/Microsoft.Sql/servers/srv_9243d320-ac4e-4f97-8e06-b1167dae5f4c/databases/db_7fe424c8-23cf-4ac3-bdc3-e21f424bdb68/extensions/Export",
"properties": {
"blobUri": "https://teststorage.blob.core.windows.net/testcontainer/samplebacpac.bacpac",
"databaseName": "db_7fe424c8-23cf-4ac3-bdc3-e21f424bdb68",
"lastModifiedTime": "lastModifiedTime",
"privateEndpointConnections": [],
"queuedTime": "09/10/2021 18:35:10",
"requestId": "10000000-0000-0000-0000-000000000002",
"requestType": "Export",
"serverName": "srv_9243d320-ac4e-4f97-8e06-b1167dae5f4c",
"status": "Completed"
}
}
Export database using database extension.
Sample request
PUT https://management.azure.com/subscriptions/0ca8cd24-0b47-4ad5-bc7e-d70e35c44adf/resourceGroups/rg_d1ef9eae-044d-4710-ba59-b82e84ad3157/providers/Microsoft.Sql/servers/srv_9243d320-ac4e-4f97-8e06-b1167dae5f4c/databases/db_7fe424c8-23cf-4ac3-bdc3-e21f424bdb68/extensions/Export?api-version=2025-01-01
{
"properties": {
"administratorLogin": "login",
"administratorLoginPassword": "password",
"authenticationType": "Sql",
"operationMode": "Export",
"storageKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"storageKeyType": "StorageAccessKey",
"storageUri": "https://teststorage.blob.core.windows.net/testcontainer/Manifest.xml"
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python export_database_using_database_extensions.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = SqlManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.database_extensions.begin_create_or_update(
resource_group_name="rg_d1ef9eae-044d-4710-ba59-b82e84ad3157",
server_name="srv_9243d320-ac4e-4f97-8e06-b1167dae5f4c",
database_name="db_7fe424c8-23cf-4ac3-bdc3-e21f424bdb68",
extension_name="Export",
parameters={
"properties": {
"administratorLogin": "login",
"administratorLoginPassword": "password",
"authenticationType": "Sql",
"operationMode": "Export",
"storageKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"storageKeyType": "StorageAccessKey",
"storageUri": "https://teststorage.blob.core.windows.net/testcontainer/Manifest.xml",
}
},
).result()
print(response)
# x-ms-original-file: 2025-01-01/ExportDatabaseUsingDatabaseExtensions.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { SqlManagementClient } = require("@azure/arm-sql");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to perform a database extension operation, like database import, database export, or polybase import
*
* @summary perform a database extension operation, like database import, database export, or polybase import
* x-ms-original-file: 2025-01-01/ExportDatabaseUsingDatabaseExtensions.json
*/
async function exportDatabaseUsingDatabaseExtension() {
const credential = new DefaultAzureCredential();
const subscriptionId = "0ca8cd24-0b47-4ad5-bc7e-d70e35c44adf";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.databaseExtensionsOperations.createOrUpdate(
"rg_d1ef9eae-044d-4710-ba59-b82e84ad3157",
"srv_9243d320-ac4e-4f97-8e06-b1167dae5f4c",
"db_7fe424c8-23cf-4ac3-bdc3-e21f424bdb68",
"Export",
{
administratorLogin: "login",
administratorLoginPassword: "password",
authenticationType: "Sql",
operationMode: "Export",
storageKey:
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
storageKeyType: "StorageAccessKey",
storageUri: "https://teststorage.blob.core.windows.net/testcontainer/Manifest.xml",
},
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.Sql.Models;
using Azure.ResourceManager.Sql;
// Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/SQL/stable/2025-01-01/examples/ExportDatabaseUsingDatabaseExtensions.json
// this example is just showing the usage of "DatabaseExtensions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this SqlDatabaseResource created on azure
// for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource
string subscriptionId = "0ca8cd24-0b47-4ad5-bc7e-d70e35c44adf";
string resourceGroupName = "rg_d1ef9eae-044d-4710-ba59-b82e84ad3157";
string serverName = "srv_9243d320-ac4e-4f97-8e06-b1167dae5f4c";
string databaseName = "db_7fe424c8-23cf-4ac3-bdc3-e21f424bdb68";
ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName);
SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId);
// invoke the operation
string extensionName = "Export";
SqlDatabaseExtension sqlDatabaseExtension = new SqlDatabaseExtension
{
OperationMode = DatabaseExtensionOperationMode.Export,
StorageKeyType = StorageKeyType.StorageAccessKey,
StorageKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
StorageUri = new Uri("https://teststorage.blob.core.windows.net/testcontainer/Manifest.xml"),
AdministratorLogin = "login",
AdministratorLoginPassword = "password",
AuthenticationType = "Sql",
};
ArmOperation<ImportExportExtensionsOperationResult> lro = await sqlDatabase.CreateOrUpdateDatabaseExtensionAsync(WaitUntil.Completed, extensionName, sqlDatabaseExtension);
ImportExportExtensionsOperationResult result = lro.Value;
Console.WriteLine($"Succeeded: {result}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"name": "Export",
"type": "Microsoft.Sql/servers/databases/extensions",
"id": "/subscriptions/0ca8cd24-0b47-4ad5-bc7e-d70e35c44adf/resourceGroups/rg_d1ef9eae-044d-4710-ba59-b82e84ad3157/providers/Microsoft.Sql/servers/srv_9243d320-ac4e-4f97-8e06-b1167dae5f4c/databases/db_7fe424c8-23cf-4ac3-bdc3-e21f424bdb68/extensions/Export",
"properties": {
"blobUri": "https://teststorage.blob.core.windows.net/testcontainer/samplebacpac.bacpac",
"databaseName": "db_7fe424c8-23cf-4ac3-bdc3-e21f424bdb68",
"lastModifiedTime": "lastModifiedTime",
"privateEndpointConnections": [],
"queuedTime": "09/10/2021 18:35:10",
"requestId": "10000000-0000-0000-0000-000000000002",
"requestType": "Export",
"serverName": "srv_9243d320-ac4e-4f97-8e06-b1167dae5f4c",
"status": "Completed"
}
}
Import database using database extension.
Sample request
PUT https://management.azure.com/subscriptions/17ca4d13-bf7d-4c33-a60e-b87a2820a325/resourceGroups/rg_062866bf-c4f4-41f9-abf0-b59132ca7924/providers/Microsoft.Sql/servers/srv_2d6be2d2-26c8-4930-8fb6-82a5e95e0e82/databases/db_2a47e946-e414-4c00-94ac-ed886bb78302/extensions/Import?api-version=2025-01-01
{
"properties": {
"administratorLogin": "login",
"administratorLoginPassword": "password",
"authenticationType": "Sql",
"operationMode": "Import",
"storageKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"storageKeyType": "StorageAccessKey",
"storageUri": "https://teststorage.blob.core.windows.net/testcontainer/Manifest.xml"
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python import_database_using_database_extensions.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = SqlManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.database_extensions.begin_create_or_update(
resource_group_name="rg_062866bf-c4f4-41f9-abf0-b59132ca7924",
server_name="srv_2d6be2d2-26c8-4930-8fb6-82a5e95e0e82",
database_name="db_2a47e946-e414-4c00-94ac-ed886bb78302",
extension_name="Import",
parameters={
"properties": {
"administratorLogin": "login",
"administratorLoginPassword": "password",
"authenticationType": "Sql",
"operationMode": "Import",
"storageKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"storageKeyType": "StorageAccessKey",
"storageUri": "https://teststorage.blob.core.windows.net/testcontainer/Manifest.xml",
}
},
).result()
print(response)
# x-ms-original-file: 2025-01-01/ImportDatabaseUsingDatabaseExtensions.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { SqlManagementClient } = require("@azure/arm-sql");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to perform a database extension operation, like database import, database export, or polybase import
*
* @summary perform a database extension operation, like database import, database export, or polybase import
* x-ms-original-file: 2025-01-01/ImportDatabaseUsingDatabaseExtensions.json
*/
async function importDatabaseUsingDatabaseExtension() {
const credential = new DefaultAzureCredential();
const subscriptionId = "17ca4d13-bf7d-4c33-a60e-b87a2820a325";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.databaseExtensionsOperations.createOrUpdate(
"rg_062866bf-c4f4-41f9-abf0-b59132ca7924",
"srv_2d6be2d2-26c8-4930-8fb6-82a5e95e0e82",
"db_2a47e946-e414-4c00-94ac-ed886bb78302",
"Import",
{
administratorLogin: "login",
administratorLoginPassword: "password",
authenticationType: "Sql",
operationMode: "Import",
storageKey:
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
storageKeyType: "StorageAccessKey",
storageUri: "https://teststorage.blob.core.windows.net/testcontainer/Manifest.xml",
},
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.Sql.Models;
using Azure.ResourceManager.Sql;
// Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/SQL/stable/2025-01-01/examples/ImportDatabaseUsingDatabaseExtensions.json
// this example is just showing the usage of "DatabaseExtensions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this SqlDatabaseResource created on azure
// for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource
string subscriptionId = "17ca4d13-bf7d-4c33-a60e-b87a2820a325";
string resourceGroupName = "rg_062866bf-c4f4-41f9-abf0-b59132ca7924";
string serverName = "srv_2d6be2d2-26c8-4930-8fb6-82a5e95e0e82";
string databaseName = "db_2a47e946-e414-4c00-94ac-ed886bb78302";
ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName);
SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId);
// invoke the operation
string extensionName = "Import";
SqlDatabaseExtension sqlDatabaseExtension = new SqlDatabaseExtension
{
OperationMode = DatabaseExtensionOperationMode.Import,
StorageKeyType = StorageKeyType.StorageAccessKey,
StorageKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
StorageUri = new Uri("https://teststorage.blob.core.windows.net/testcontainer/Manifest.xml"),
AdministratorLogin = "login",
AdministratorLoginPassword = "password",
AuthenticationType = "Sql",
};
ArmOperation<ImportExportExtensionsOperationResult> lro = await sqlDatabase.CreateOrUpdateDatabaseExtensionAsync(WaitUntil.Completed, extensionName, sqlDatabaseExtension);
ImportExportExtensionsOperationResult result = lro.Value;
Console.WriteLine($"Succeeded: {result}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"name": "Import",
"type": "Microsoft.Sql/servers/databases/extensions",
"id": "/subscriptions/17ca4d13-bf7d-4c33-a60e-b87a2820a325/resourceGroups/rg_062866bf-c4f4-41f9-abf0-b59132ca7924/providers/Microsoft.Sql/servers/srv_2d6be2d2-26c8-4930-8fb6-82a5e95e0e82/databases/db_2a47e946-e414-4c00-94ac-ed886bb78302/extensions/Import",
"properties": {
"blobUri": "https://teststorage.blob.core.windows.net/testcontainer/samplebacpac.bacpac",
"databaseName": "db_2a47e946-e414-4c00-94ac-ed886bb78302",
"lastModifiedTime": "lastModifiedTime",
"privateEndpointConnections": [],
"queuedTime": "09/10/2021 18:35:10",
"requestId": "10000000-0000-0000-0000-000000000002",
"requestType": "Import",
"serverName": "srv_2d6be2d2-26c8-4930-8fb6-82a5e95e0e82",
"status": "Completed"
}
}
Definitions
createdByType
Enumeration
The type of identity that created the resource.
| Value |
Description |
|
User
|
|
|
Application
|
|
|
ManagedIdentity
|
|
|
Key
|
|
DatabaseExtensions
Object
An Import, Export, or PolybaseImport resource.
| Name |
Type |
Description |
|
id
|
string
(arm-id)
|
Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"
|
|
name
|
string
|
The name of the resource
|
|
properties.administratorLogin
|
string
|
Administrator login name. If AuthenticationType is ManagedIdentity, this field should specify the Managed Identity's resource ID.
|
|
properties.administratorLoginPassword
|
string
(password)
|
Administrator login password. If AuthenticationType is ManagedIdentity, this field should not be specified.
|
|
properties.authenticationType
|
string
|
Authentication type used to access the SQL: Sql, ADPassword or ManagedIdentity.
|
|
properties.databaseEdition
|
string
|
Database edition for the newly created database in the case of an import operation.
|
|
properties.maxSizeBytes
|
string
|
Database max size in bytes for the newly created database in the case of an import operation.
|
|
properties.networkIsolation
|
NetworkIsolationSettings
|
Optional resource information to enable network isolation for request.
|
|
properties.operationMode
|
OperationMode
|
Operation mode of the operation: Import, Export, or PolybaseImport.
|
|
properties.serviceObjectiveName
|
string
|
Database service level objective for the newly created database in the case of an import operation.
|
|
properties.storageKey
|
string
|
Storage key for the storage account. If StorageKeyType is ManagedIdentity, this field should specify the Managed Identity's resource ID.
|
|
properties.storageKeyType
|
StorageKeyType
|
Storage key type: StorageAccessKey, SharedAccessKey or ManagedIdentity.
|
|
properties.storageUri
|
string
|
Storage Uri for the storage account.
|
|
systemData
|
systemData
|
Azure Resource Manager metadata containing createdBy and modifiedBy information.
|
|
type
|
string
|
The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
|
ErrorAdditionalInfo
Object
The resource management error additional info.
| Name |
Type |
Description |
|
info
|
object
|
The additional info.
|
|
type
|
string
|
The additional info type.
|
ErrorDetail
Object
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
Object
Error response
| Name |
Type |
Description |
|
error
|
ErrorDetail
|
The error object.
|
ImportExportExtensionsOperationResult
Object
An Extension operation result resource.
| Name |
Type |
Description |
|
id
|
string
(arm-id)
|
Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"
|
|
name
|
string
|
The name of the resource
|
|
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.
|
|
systemData
|
systemData
|
Azure Resource Manager metadata containing createdBy and modifiedBy information.
|
|
type
|
string
|
The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
|
NetworkIsolationSettings
Object
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.
|
OperationMode
Enumeration
Operation mode of the operation: Import, Export, or PolybaseImport.
| Value |
Description |
|
PolybaseImport
|
PolybaseImport
|
|
Import
|
Import
|
|
Export
|
Export
|
PrivateEndpointConnectionRequestStatus
Object
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
Enumeration
Storage key type: StorageAccessKey, SharedAccessKey or ManagedIdentity.
| Value |
Description |
|
SharedAccessKey
|
SharedAccessKey
|
|
StorageAccessKey
|
StorageAccessKey
|
|
ManagedIdentity
|
ManagedIdentity
|
systemData
Object
Metadata pertaining to creation and last modification of the resource.
| Name |
Type |
Description |
|
createdAt
|
string
(date-time)
|
The timestamp of resource creation (UTC).
|
|
createdBy
|
string
|
The identity that created the resource.
|
|
createdByType
|
createdByType
|
The type of identity that created the resource.
|
|
lastModifiedAt
|
string
(date-time)
|
The timestamp of resource last modification (UTC)
|
|
lastModifiedBy
|
string
|
The identity that last modified the resource.
|
|
lastModifiedByType
|
createdByType
|
The type of identity that last modified the resource.
|