Importiert einen Bacpac in eine neue Datenbank.
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/import?api-version=2025-01-01
URI-Parameter
| Name |
In |
Erforderlich |
Typ |
Beschreibung |
|
resourceGroupName
|
path |
True
|
string
minLength: 1 maxLength: 90
|
Der Name der Ressourcengruppe. Bei dem Namen wird die Groß-/Kleinschreibung nicht beachtet.
|
|
serverName
|
path |
True
|
string
|
Name des Servers
|
|
subscriptionId
|
path |
True
|
string
(uuid)
|
Die ID des Zielabonnements. Der Wert muss eine UUID sein.
|
|
api-version
|
query |
True
|
string
minLength: 1
|
Die API-Version, die für diesen Vorgang verwendet werden soll.
|
Anforderungstext
| Name |
Erforderlich |
Typ |
Beschreibung |
|
administratorLogin
|
True
|
string
|
Administratoranmeldungsname. Wenn AuthenticationType "ManagedIdentity" ist, sollte dieses Feld die Ressourcen-ID der verwalteten Identität angeben.
|
|
storageKey
|
True
|
string
|
Speicherschlüssel für das Speicherkonto. Wenn "StorageKeyType" "ManagedIdentity" lautet, sollte dieses Feld die Ressourcen-ID der verwalteten Identität angeben.
|
|
storageKeyType
|
True
|
StorageKeyType
|
Speicherschlüsseltyp: StorageAccessKey, SharedAccessKey oder ManagedIdentity.
|
|
storageUri
|
True
|
string
|
Speicher-URI.
|
|
administratorLoginPassword
|
|
string
(password)
|
Administratoranmeldungskennwort. Wenn AuthenticationType managedIdentity ist, sollte dieses Feld nicht angegeben werden.
|
|
authenticationType
|
|
string
|
Typ der Anmeldeinformationen, die für den Zugriff auf den ZIEL-SQL-Server bereitgestellt werden: SQL, ADPassword oder ManagedIdentity.
|
|
databaseName
|
|
string
|
Name der Importdatenbank.
|
|
edition
|
|
string
|
Edition der Importdatenbank.
|
|
maxSizeBytes
|
|
string
|
Maximale Größe in Byte für die Importdatenbank.
|
|
networkIsolation
|
|
NetworkIsolationSettings
|
Optionale Ressourceninformationen zum Aktivieren der Netzwerkisolation für die Anforderung.
|
|
serviceObjectiveName
|
|
string
|
Zielname der Dienstebene der Importdatenbank.
|
Antworten
| Name |
Typ |
Beschreibung |
|
200 OK
|
ImportExportOperationResult
|
Azure-Operation erfolgreich abgeschlossen.
|
|
202 Accepted
|
|
Ressourcenvorgang akzeptiert.
Header
- Location: string
- Retry-After: integer
|
|
Other Status Codes
|
ErrorResponse
|
Unerwartete Fehlerantwort.
|
Sicherheit
azure_auth
Azure Active Directory OAuth2 Flow.
Typ:
oauth2
Ablauf:
implicit
Autorisierungs-URL:
https://login.microsoftonline.com/common/oauth2/authorize
Bereiche
| Name |
Beschreibung |
|
user_impersonation
|
Identitätswechsel ihres Benutzerkontos
|
Beispiele
Imports to a new database, using Managed Identity for the SQL server and storage account.
Beispielanforderung
POST https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/import?api-version=2025-01-01
{
"administratorLogin": "/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/rgName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityName",
"authenticationType": "ManagedIdentity",
"databaseName": "testdb",
"storageKey": "/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/rgName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityName",
"storageKeyType": "ManagedIdentity",
"storageUri": "https://test.blob.core.windows.net/test.bacpac"
}
import com.azure.resourcemanager.sql.models.ImportNewDatabaseDefinition;
import com.azure.resourcemanager.sql.models.StorageKeyType;
/**
* Samples for Servers ImportDatabase.
*/
public final class Main {
/*
* x-ms-original-file: 2025-01-01/ImportNewDatabaseWithManagedIdentity.json
*/
/**
* Sample code: Imports to a new database, using Managed Identity for the SQL server and storage account.
*
* @param manager Entry point to SqlServerManager.
*/
public static void importsToANewDatabaseUsingManagedIdentityForTheSQLServerAndStorageAccount(
com.azure.resourcemanager.sql.SqlServerManager manager) {
manager.serviceClient().getServers().importDatabase("Default-SQL-SouthEastAsia", "testsvr",
new ImportNewDatabaseDefinition().withDatabaseName("testdb")
.withStorageKeyType(StorageKeyType.MANAGED_IDENTITY).withStorageKey("fakeTokenPlaceholder")
.withStorageUri("https://test.blob.core.windows.net/test.bacpac")
.withAdministratorLogin(
"/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/rgName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityName")
.withAuthenticationType("ManagedIdentity"),
com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python import_new_database_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.servers.begin_import_database(
resource_group_name="Default-SQL-SouthEastAsia",
server_name="testsvr",
parameters={
"administratorLogin": "/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/rgName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityName",
"authenticationType": "ManagedIdentity",
"databaseName": "testdb",
"storageKey": "/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/rgName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityName",
"storageKeyType": "ManagedIdentity",
"storageUri": "https://test.blob.core.windows.net/test.bacpac",
},
).result()
print(response)
# x-ms-original-file: 2025-01-01/ImportNewDatabaseWithManagedIdentity.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 imports a bacpac into a new database.
*
* @summary imports a bacpac into a new database.
* x-ms-original-file: 2025-01-01/ImportNewDatabaseWithManagedIdentity.json
*/
async function importsToANewDatabaseUsingManagedIdentityForTheSQLServerAndStorageAccount() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.servers.importDatabase("Default-SQL-SouthEastAsia", "testsvr", {
administratorLogin:
"/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/rgName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityName",
authenticationType: "ManagedIdentity",
databaseName: "testdb",
storageKey:
"/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/rgName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityName",
storageKeyType: "ManagedIdentity",
storageUri: "https://test.blob.core.windows.net/test.bacpac",
});
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.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
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/ImportNewDatabaseWithManagedIdentity.json
// this example is just showing the usage of "Servers_ImportDatabase" 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 SqlServerResource created on azure
// for more information of creating SqlServerResource, please refer to the document of SqlServerResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string serverName = "testsvr";
ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId);
// invoke the operation
DatabaseImportDefinition databaseImportDefinition = new DatabaseImportDefinition(StorageKeyType.ManagedIdentity, "/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/rgName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityName", new Uri("https://test.blob.core.windows.net/test.bacpac"), "/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/rgName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityName")
{
DatabaseName = "testdb",
AuthenticationType = "ManagedIdentity",
};
ArmOperation<ImportExportOperationResult> lro = await sqlServer.ImportDatabaseAsync(WaitUntil.Completed, databaseImportDefinition);
ImportExportOperationResult 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
Beispiel für eine Antwort
{
"name": "9d9a794a-5cec-4f23-af70-d29511b522a4",
"type": "Microsoft.Sql/servers/databases/importExportOperationResults",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb/importExportOperationResults/9d9a794a-5cec-4f23-af70-d29511b522a4",
"properties": {
"blobUri": "https://test.blob.core.windows.net/test.bacpac",
"databaseName": "testdb",
"lastModifiedTime": "2/2/2020 8:34:47 PM",
"queuedTime": "2/2/2020 8:33:27 PM",
"requestId": "9d9a794a-5cec-4f23-af70-d29511b522a4",
"requestType": "Import",
"serverName": "testsvr.database.windows.net",
"status": "Completed"
}
}
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, using private link for the SQL server and storage account.
Beispielanforderung
POST https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/import?api-version=2025-01-01
{
"administratorLogin": "login",
"administratorLoginPassword": "password",
"authenticationType": "Sql",
"databaseName": "testdb",
"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"
},
"storageKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==",
"storageKeyType": "StorageAccessKey",
"storageUri": "https://test.blob.core.windows.net/test.bacpac"
}
import com.azure.resourcemanager.sql.models.ImportNewDatabaseDefinition;
import com.azure.resourcemanager.sql.models.NetworkIsolationSettings;
import com.azure.resourcemanager.sql.models.StorageKeyType;
/**
* Samples for Servers ImportDatabase.
*/
public final class Main {
/*
* x-ms-original-file: 2025-01-01/ImportNewDatabaseWithNetworkIsolation.json
*/
/**
* Sample code: Imports to a new database, using private link for the SQL server and storage account.
*
* @param manager Entry point to SqlServerManager.
*/
public static void importsToANewDatabaseUsingPrivateLinkForTheSQLServerAndStorageAccount(
com.azure.resourcemanager.sql.SqlServerManager manager) {
manager.serviceClient().getServers().importDatabase("Default-SQL-SouthEastAsia", "testsvr",
new ImportNewDatabaseDefinition().withDatabaseName("testdb")
.withStorageKeyType(StorageKeyType.STORAGE_ACCESS_KEY).withStorageKey("fakeTokenPlaceholder")
.withStorageUri("https://test.blob.core.windows.net/test.bacpac").withAdministratorLogin("login")
.withAdministratorLoginPassword("fakeTokenPlaceholder").withAuthenticationType("Sql")
.withNetworkIsolation(new NetworkIsolationSettings().withStorageAccountResourceId(
"/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Storage/storageAccounts/test-privatelink")
.withSqlServerResourceId(
"/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr")),
com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python import_new_database_with_network_isolation.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.servers.begin_import_database(
resource_group_name="Default-SQL-SouthEastAsia",
server_name="testsvr",
parameters={
"administratorLogin": "login",
"administratorLoginPassword": "password",
"authenticationType": "Sql",
"databaseName": "testdb",
"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",
},
"storageKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==",
"storageKeyType": "StorageAccessKey",
"storageUri": "https://test.blob.core.windows.net/test.bacpac",
},
).result()
print(response)
# x-ms-original-file: 2025-01-01/ImportNewDatabaseWithNetworkIsolation.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 imports a bacpac into a new database.
*
* @summary imports a bacpac into a new database.
* x-ms-original-file: 2025-01-01/ImportNewDatabaseWithNetworkIsolation.json
*/
async function importsToANewDatabaseUsingPrivateLinkForTheSQLServerAndStorageAccount() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.servers.importDatabase("Default-SQL-SouthEastAsia", "testsvr", {
administratorLogin: "login",
administratorLoginPassword: "password",
authenticationType: "Sql",
databaseName: "testdb",
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",
},
storageKey:
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==",
storageKeyType: "StorageAccessKey",
storageUri: "https://test.blob.core.windows.net/test.bacpac",
});
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.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
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/ImportNewDatabaseWithNetworkIsolation.json
// this example is just showing the usage of "Servers_ImportDatabase" 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 SqlServerResource created on azure
// for more information of creating SqlServerResource, please refer to the document of SqlServerResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string serverName = "testsvr";
ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId);
// invoke the operation
DatabaseImportDefinition databaseImportDefinition = new DatabaseImportDefinition(StorageKeyType.StorageAccessKey, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==", new Uri("https://test.blob.core.windows.net/test.bacpac"), "login")
{
DatabaseName = "testdb",
AdministratorLoginPassword = "password",
AuthenticationType = "Sql",
NetworkIsolation = new NetworkIsolationSettings
{
StorageAccountResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Storage/storageAccounts/test-privatelink"),
SqlServerResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr"),
},
};
ArmOperation<ImportExportOperationResult> lro = await sqlServer.ImportDatabaseAsync(WaitUntil.Completed, databaseImportDefinition);
ImportExportOperationResult 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
Beispiel für eine Antwort
{
"name": "9d9a794a-5cec-4f23-af70-d29511b522a4",
"type": "Microsoft.Sql/servers/databases/importExportOperationResults",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb/importExportOperationResults/9d9a794a-5cec-4f23-af70-d29511b522a4",
"properties": {
"blobUri": "https://test.blob.core.windows.net/test.bacpac",
"databaseName": "testdb",
"lastModifiedTime": "2/2/2020 8:34:47 PM",
"queuedTime": "2/2/2020 8:33:27 PM",
"requestId": "9d9a794a-5cec-4f23-af70-d29511b522a4",
"requestType": "Import",
"serverName": "testsvr.database.windows.net",
"status": "Completed"
}
}
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.
Beispielanforderung
POST https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/import?api-version=2025-01-01
{
"administratorLogin": "login",
"administratorLoginPassword": "password",
"authenticationType": "Sql",
"databaseName": "testdb",
"storageKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==",
"storageKeyType": "StorageAccessKey",
"storageUri": "https://test.blob.core.windows.net/test.bacpac"
}
import com.azure.resourcemanager.sql.models.ImportNewDatabaseDefinition;
import com.azure.resourcemanager.sql.models.StorageKeyType;
/**
* Samples for Servers ImportDatabase.
*/
public final class Main {
/*
* x-ms-original-file: 2025-01-01/ImportNewDatabase.json
*/
/**
* Sample code: Imports to a new database.
*
* @param manager Entry point to SqlServerManager.
*/
public static void importsToANewDatabase(com.azure.resourcemanager.sql.SqlServerManager manager) {
manager.serviceClient().getServers().importDatabase("Default-SQL-SouthEastAsia", "testsvr",
new ImportNewDatabaseDefinition().withDatabaseName("testdb")
.withStorageKeyType(StorageKeyType.STORAGE_ACCESS_KEY).withStorageKey("fakeTokenPlaceholder")
.withStorageUri("https://test.blob.core.windows.net/test.bacpac").withAdministratorLogin("login")
.withAdministratorLoginPassword("fakeTokenPlaceholder").withAuthenticationType("Sql"),
com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python import_new_database.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.servers.begin_import_database(
resource_group_name="Default-SQL-SouthEastAsia",
server_name="testsvr",
parameters={
"administratorLogin": "login",
"administratorLoginPassword": "password",
"authenticationType": "Sql",
"databaseName": "testdb",
"storageKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==",
"storageKeyType": "StorageAccessKey",
"storageUri": "https://test.blob.core.windows.net/test.bacpac",
},
).result()
print(response)
# x-ms-original-file: 2025-01-01/ImportNewDatabase.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 imports a bacpac into a new database.
*
* @summary imports a bacpac into a new database.
* x-ms-original-file: 2025-01-01/ImportNewDatabase.json
*/
async function importsToANewDatabase() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.servers.importDatabase("Default-SQL-SouthEastAsia", "testsvr", {
administratorLogin: "login",
administratorLoginPassword: "password",
authenticationType: "Sql",
databaseName: "testdb",
storageKey:
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==",
storageKeyType: "StorageAccessKey",
storageUri: "https://test.blob.core.windows.net/test.bacpac",
});
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.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
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/ImportNewDatabase.json
// this example is just showing the usage of "Servers_ImportDatabase" 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 SqlServerResource created on azure
// for more information of creating SqlServerResource, please refer to the document of SqlServerResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string serverName = "testsvr";
ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId);
// invoke the operation
DatabaseImportDefinition databaseImportDefinition = new DatabaseImportDefinition(StorageKeyType.StorageAccessKey, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==", new Uri("https://test.blob.core.windows.net/test.bacpac"), "login")
{
DatabaseName = "testdb",
AdministratorLoginPassword = "password",
AuthenticationType = "Sql",
};
ArmOperation<ImportExportOperationResult> lro = await sqlServer.ImportDatabaseAsync(WaitUntil.Completed, databaseImportDefinition);
ImportExportOperationResult 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
Beispiel für eine Antwort
{
"name": "9d9a794a-5cec-4f23-af70-d29511b522a4",
"type": "Microsoft.Sql/servers/databases/importExportOperationResults",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb/importExportOperationResults/9d9a794a-5cec-4f23-af70-d29511b522a4",
"properties": {
"blobUri": "https://test.blob.core.windows.net/test.bacpac",
"databaseName": "testdb",
"lastModifiedTime": "2/2/2020 8:34:47 PM",
"queuedTime": "2/2/2020 8:33:27 PM",
"requestId": "9d9a794a-5cec-4f23-af70-d29511b522a4",
"requestType": "Import",
"serverName": "testsvr.database.windows.net",
"status": "Completed"
}
}
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
Definitionen
createdByType
Enumeration
Der Identitätstyp, der die Ressource erstellt hat.
| Wert |
Beschreibung |
|
User
|
|
|
Application
|
|
|
ManagedIdentity
|
|
|
Key
|
|
ErrorAdditionalInfo
Objekt
Der Ressourcenverwaltungsfehler zusätzliche Informationen.
| Name |
Typ |
Beschreibung |
|
info
|
object
|
Die zusätzlichen Informationen.
|
|
type
|
string
|
Der zusätzliche Informationstyp.
|
ErrorDetail
Objekt
Das Fehlerdetails.
| Name |
Typ |
Beschreibung |
|
additionalInfo
|
ErrorAdditionalInfo[]
|
Die zusätzlichen Informationen des Fehlers.
|
|
code
|
string
|
Der Fehlercode.
|
|
details
|
ErrorDetail[]
|
Die Fehlerdetails.
|
|
message
|
string
|
Die Fehlermeldung.
|
|
target
|
string
|
Das Fehlerziel.
|
ErrorResponse
Objekt
Fehlerantwort
| Name |
Typ |
Beschreibung |
|
error
|
ErrorDetail
|
Das Fehlerobjekt.
|
ImportExportOperationResult
Objekt
Eine Ergebnisressource des ImportExport-Vorgangs.
| Name |
Typ |
Beschreibung |
|
id
|
string
(arm-id)
|
Vollqualifizierte Ressourcen-ID für die Ressource. Z. B. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"
|
|
name
|
string
|
Der Name der Ressource
|
|
properties.blobUri
|
string
|
Blob-URI.
|
|
properties.databaseName
|
string
|
Datenbankname.
|
|
properties.errorMessage
|
string
|
Fehlermeldung.
|
|
properties.lastModifiedTime
|
string
|
Zeitpunkt der letzten Änderung.
|
|
properties.privateEndpointConnections
|
PrivateEndpointConnectionRequestStatus[]
|
Ruft den Status privater Endpunkte ab, die dieser Anforderung zugeordnet sind.
|
|
properties.queuedTime
|
string
|
In die Warteschlange eingereihte Zeit.
|
|
properties.requestId
|
string
(uuid)
|
Anforderungs-ID.
|
|
properties.requestType
|
string
|
Anforderungstyp.
|
|
properties.serverName
|
string
|
Server-Name.
|
|
properties.status
|
string
|
Vorgangsstatus.
|
|
systemData
|
systemData
|
Azure Resource Manager-Metadaten, die createdBy und modifiedBy-Informationen enthalten.
|
|
type
|
string
|
Der Typ der Ressource. Zum Beispiel "Microsoft. Compute/virtualMachines" oder "Microsoft. Speicher/Speicherkonten"
|
ImportNewDatabaseDefinition
Objekt
Enthält die informationen, die zum Ausführen des Importvorgangs für neue Datenbank erforderlich sind.
| Name |
Typ |
Beschreibung |
|
administratorLogin
|
string
|
Administratoranmeldungsname. Wenn AuthenticationType "ManagedIdentity" ist, sollte dieses Feld die Ressourcen-ID der verwalteten Identität angeben.
|
|
administratorLoginPassword
|
string
(password)
|
Administratoranmeldungskennwort. Wenn AuthenticationType managedIdentity ist, sollte dieses Feld nicht angegeben werden.
|
|
authenticationType
|
string
|
Typ der Anmeldeinformationen, die für den Zugriff auf den ZIEL-SQL-Server bereitgestellt werden: SQL, ADPassword oder ManagedIdentity.
|
|
databaseName
|
string
|
Name der Importdatenbank.
|
|
edition
|
string
|
Edition der Importdatenbank.
|
|
maxSizeBytes
|
string
|
Maximale Größe in Byte für die Importdatenbank.
|
|
networkIsolation
|
NetworkIsolationSettings
|
Optionale Ressourceninformationen zum Aktivieren der Netzwerkisolation für die Anforderung.
|
|
serviceObjectiveName
|
string
|
Zielname der Dienstebene der Importdatenbank.
|
|
storageKey
|
string
|
Speicherschlüssel für das Speicherkonto. Wenn "StorageKeyType" "ManagedIdentity" lautet, sollte dieses Feld die Ressourcen-ID der verwalteten Identität angeben.
|
|
storageKeyType
|
StorageKeyType
|
Speicherschlüsseltyp: StorageAccessKey, SharedAccessKey oder ManagedIdentity.
|
|
storageUri
|
string
|
Speicher-URI.
|
NetworkIsolationSettings
Objekt
Enthält die ARM-Ressourcen, für die eine private Endpunktverbindung erstellt werden soll.
| Name |
Typ |
Beschreibung |
|
sqlServerResourceId
|
string
(arm-id)
|
Die Ressourcen-ID für den SQL-Server, der das Ziel dieser Anforderung ist. Wenn festgelegt, wird eine private Endpunktverbindung für den SQL-Server erstellt. Muss mit dem Server übereinstimmen, der das Ziel des Vorgangs ist.
|
|
storageAccountResourceId
|
string
(arm-id)
|
Die Ressourcen-ID für das Speicherkonto, das zum Speichern der BACPAC-Datei verwendet wird. Bei Festlegung wird für das Speicherkonto eine private Endpunktverbindung erstellt. Muss mit dem Speicherkonto übereinstimmen, das für den Parameter "StorageUri" verwendet wird.
|
PrivateEndpointConnectionRequestStatus
Objekt
Enthält den Status der privaten Endpunktverbindungsanforderungen.
| Name |
Typ |
Beschreibung |
|
privateEndpointConnectionName
|
string
|
Der Verbindungsname für den privaten Endpunkt.
|
|
privateLinkServiceId
|
string
|
Ressourcen-ID, für die der private Endpunkt erstellt wird.
|
|
status
|
string
|
Status dieser privaten Endpunktverbindung.
|
StorageKeyType
Enumeration
Speicherschlüsseltyp: StorageAccessKey, SharedAccessKey oder ManagedIdentity.
| Wert |
Beschreibung |
|
SharedAccessKey
|
Gemeinsamer Zugriffsschlüssel
|
|
StorageAccessKey
|
StorageAccessKey
|
|
ManagedIdentity
|
ManagedIdentity
|
systemData
Objekt
Metadaten zur Erstellung und letzten Änderung der Ressource.
| Name |
Typ |
Beschreibung |
|
createdAt
|
string
(date-time)
|
Der Zeitstempel der Ressourcenerstellung (UTC).
|
|
createdBy
|
string
|
Die Identität, die die Ressource erstellt hat.
|
|
createdByType
|
createdByType
|
Der Identitätstyp, der die Ressource erstellt hat.
|
|
lastModifiedAt
|
string
(date-time)
|
Der Zeitstempel der letzten Änderung der Ressource (UTC)
|
|
lastModifiedBy
|
string
|
Die Identität, die die Ressource zuletzt geändert hat.
|
|
lastModifiedByType
|
createdByType
|
Der Identitätstyp, der die Ressource zuletzt geändert hat.
|