Importe un bacpac dans une nouvelle base de données.
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/import?api-version=2025-01-01
Paramètres URI
| Nom |
Dans |
Obligatoire |
Type |
Description |
|
resourceGroupName
|
path |
True
|
string
minLength: 1 maxLength: 90
|
Nom du groupe de ressources. Le nom ne respecte pas la casse.
|
|
serverName
|
path |
True
|
string
|
Le nom du serveur
|
|
subscriptionId
|
path |
True
|
string
(uuid)
|
ID de l’abonnement cible. La valeur doit être un UUID.
|
|
api-version
|
query |
True
|
string
minLength: 1
|
Version de l’API à utiliser pour cette opération.
|
Corps de la demande
| Nom |
Obligatoire |
Type |
Description |
|
administratorLogin
|
True
|
string
|
Nom de connexion administrateur. Si AuthenticationType est ManagedIdentity, ce champ doit spécifier l’ID de ressource de l’identité managée.
|
|
storageKey
|
True
|
string
|
Clé de stockage pour le compte de stockage. Si StorageKeyType est ManagedIdentity, ce champ doit spécifier l’ID de ressource de l’identité managée.
|
|
storageKeyType
|
True
|
StorageKeyType
|
Type de clé de stockage : StorageAccessKey, SharedAccessKey ou ManagedIdentity.
|
|
storageUri
|
True
|
string
|
Uri de stockage.
|
|
administratorLoginPassword
|
|
string
(password)
|
Mot de passe de connexion administrateur. Si AuthenticationType est ManagedIdentity, ce champ ne doit pas être spécifié.
|
|
authenticationType
|
|
string
|
Type d’informations d’identification fournies pour l’accès au serveur SQL cible : SQL, ADPassword ou ManagedIdentity.
|
|
databaseName
|
|
string
|
Nom de la base de données d’importation.
|
|
edition
|
|
string
|
Édition de la base de données d’importation.
|
|
maxSizeBytes
|
|
string
|
Taille maximale en octets pour la base de données d’importation.
|
|
networkIsolation
|
|
NetworkIsolationSettings
|
Informations de ressource facultatives pour activer l’isolation réseau pour la requête.
|
|
serviceObjectiveName
|
|
string
|
Nom de l’objectif de niveau de service de la base de données d’importation.
|
Réponses
| Nom |
Type |
Description |
|
200 OK
|
ImportExportOperationResult
|
Opération Azure terminée avec succès.
|
|
202 Accepted
|
|
Exploitation des ressources acceptée.
En-têtes
- Location: string
- Retry-After: integer
|
|
Other Status Codes
|
ErrorResponse
|
Réponse d’erreur inattendue.
|
Sécurité
azure_auth
Azure Active Directory OAuth2 Flow.
Type:
oauth2
Flux:
implicit
URL d’autorisation:
https://login.microsoftonline.com/common/oauth2/authorize
Étendues
| Nom |
Description |
|
user_impersonation
|
emprunter l’identité de votre compte d’utilisateur
|
Exemples
Imports to a new database, using Managed Identity for the SQL server and storage account.
Exemple de requête
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
Exemple de réponse
{
"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.
Exemple de requête
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
Exemple de réponse
{
"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.
Exemple de requête
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
Exemple de réponse
{
"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
Définitions
createdByType
Énumération
Type d’identité qui a créé la ressource.
| Valeur |
Description |
|
User
|
|
|
Application
|
|
|
ManagedIdentity
|
|
|
Key
|
|
ErrorAdditionalInfo
Objet
Informations supplémentaires sur l’erreur de gestion des ressources.
| Nom |
Type |
Description |
|
info
|
object
|
Informations supplémentaires.
|
|
type
|
string
|
Type d’informations supplémentaire.
|
ErrorDetail
Objet
Détail de l’erreur.
| Nom |
Type |
Description |
|
additionalInfo
|
ErrorAdditionalInfo[]
|
Informations supplémentaires sur l’erreur.
|
|
code
|
string
|
Code d’erreur.
|
|
details
|
ErrorDetail[]
|
Détails de l’erreur.
|
|
message
|
string
|
Message d’erreur.
|
|
target
|
string
|
Cible d’erreur.
|
ErrorResponse
Objet
Réponse d’erreur
ImportExportOperationResult
Objet
Ressource de résultat de l’opération ImportExport.
| Nom |
Type |
Description |
|
id
|
string
(arm-id)
|
ID de ressource complet pour la ressource. Par exemple, « /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} »
|
|
name
|
string
|
Nom de la ressource
|
|
properties.blobUri
|
string
|
Uri d’objet blob.
|
|
properties.databaseName
|
string
|
Nom de la base de données.
|
|
properties.errorMessage
|
string
|
Message d’erreur.
|
|
properties.lastModifiedTime
|
string
|
Heure de dernière modification.
|
|
properties.privateEndpointConnections
|
PrivateEndpointConnectionRequestStatus[]
|
Obtient l’état des points de terminaison privés associés à cette requête.
|
|
properties.queuedTime
|
string
|
Heure mise en file d’attente.
|
|
properties.requestId
|
string
(uuid)
|
ID de demande.
|
|
properties.requestType
|
string
|
Type de requête.
|
|
properties.serverName
|
string
|
Nom du serveur.
|
|
properties.status
|
string
|
État de l’opération.
|
|
systemData
|
systemData
|
Azure Resource Manager : métadonnées contenant des informations createdBy et modifiedBy.
|
|
type
|
string
|
Type de la ressource. Par exemple : « Microsoft. Calcul/virtualMachines » ou « Microsoft. StorageAccounts"
|
ImportNewDatabaseDefinition
Objet
Contient les informations nécessaires pour effectuer l’opération d’importation pour la nouvelle base de données.
| Nom |
Type |
Description |
|
administratorLogin
|
string
|
Nom de connexion administrateur. Si AuthenticationType est ManagedIdentity, ce champ doit spécifier l’ID de ressource de l’identité managée.
|
|
administratorLoginPassword
|
string
(password)
|
Mot de passe de connexion administrateur. Si AuthenticationType est ManagedIdentity, ce champ ne doit pas être spécifié.
|
|
authenticationType
|
string
|
Type d’informations d’identification fournies pour l’accès au serveur SQL cible : SQL, ADPassword ou ManagedIdentity.
|
|
databaseName
|
string
|
Nom de la base de données d’importation.
|
|
edition
|
string
|
Édition de la base de données d’importation.
|
|
maxSizeBytes
|
string
|
Taille maximale en octets pour la base de données d’importation.
|
|
networkIsolation
|
NetworkIsolationSettings
|
Informations de ressource facultatives pour activer l’isolation réseau pour la requête.
|
|
serviceObjectiveName
|
string
|
Nom de l’objectif de niveau de service de la base de données d’importation.
|
|
storageKey
|
string
|
Clé de stockage pour le compte de stockage. Si StorageKeyType est ManagedIdentity, ce champ doit spécifier l’ID de ressource de l’identité managée.
|
|
storageKeyType
|
StorageKeyType
|
Type de clé de stockage : StorageAccessKey, SharedAccessKey ou ManagedIdentity.
|
|
storageUri
|
string
|
Uri de stockage.
|
NetworkIsolationSettings
Objet
Contient les ressources ARM pour lesquelles créer une connexion de point de terminaison privé.
| Nom |
Type |
Description |
|
sqlServerResourceId
|
string
(arm-id)
|
ID de ressource pour le serveur SQL qui est la cible de cette requête. Si elle est définie, la connexion de point de terminaison privé est créée pour le serveur SQL. Doit correspondre au serveur qui est la cible de l’opération.
|
|
storageAccountResourceId
|
string
(arm-id)
|
ID de ressource du compte de stockage utilisé pour stocker le fichier BACPAC. Si elle est définie, la connexion de point de terminaison privé est créée pour le compte de stockage. Doit correspondre au compte de stockage utilisé pour le paramètre StorageUri.
|
PrivateEndpointConnectionRequestStatus
Objet
Contient l’état des demandes de connexion de point de terminaison privé.
| Nom |
Type |
Description |
|
privateEndpointConnectionName
|
string
|
Nom de connexion du point de terminaison privé.
|
|
privateLinkServiceId
|
string
|
ID de ressource pour lequel le point de terminaison privé est créé.
|
|
status
|
string
|
État de cette connexion de point de terminaison privé.
|
StorageKeyType
Énumération
Type de clé de stockage : StorageAccessKey, SharedAccessKey ou ManagedIdentity.
| Valeur |
Description |
|
SharedAccessKey
|
CléD'AccèsPartagée
|
|
StorageAccessKey
|
StorageAccessKey
|
|
ManagedIdentity
|
ManagedIdentity
|
systemData
Objet
Métadonnées relatives à la création et à la dernière modification de la ressource.
| Nom |
Type |
Description |
|
createdAt
|
string
(date-time)
|
Horodatage de la création de ressources (UTC).
|
|
createdBy
|
string
|
Identité qui a créé la ressource.
|
|
createdByType
|
createdByType
|
Type d’identité qui a créé la ressource.
|
|
lastModifiedAt
|
string
(date-time)
|
Horodatage de la dernière modification de ressource (UTC)
|
|
lastModifiedBy
|
string
|
Identité qui a modifié la ressource pour la dernière fois.
|
|
lastModifiedByType
|
createdByType
|
Type d’identité qui a modifié la ressource pour la dernière fois.
|