Importerar ett bacpac till en ny databas.
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/import?api-version=2025-01-01
URI-parametrar
| Name |
I |
Obligatorisk |
Typ |
Description |
|
databaseName
|
path |
True
|
string
|
Namnet på databasen.
|
|
resourceGroupName
|
path |
True
|
string
minLength: 1 maxLength: 90
|
Namnet på resursgruppen. Namnet är skiftlägesokänsligt.
|
|
serverName
|
path |
True
|
string
|
Namnet på servern.
|
|
subscriptionId
|
path |
True
|
string
(uuid)
|
ID för målprenumerationen. Värdet måste vara ett UUID.
|
|
api-version
|
query |
True
|
string
minLength: 1
|
Den API-version som ska användas för den här åtgärden.
|
Begärandetext
| Name |
Obligatorisk |
Typ |
Description |
|
administratorLogin
|
True
|
string
|
Administratörens inloggningsnamn. Om AuthenticationType är ManagedIdentity ska det här fältet ange den hanterade identitetens resurs-ID.
|
|
storageKey
|
True
|
string
|
Lagringsnyckel för lagringskontot. Om StorageKeyType är ManagedIdentity ska det här fältet ange den hanterade identitetens resurs-ID.
|
|
storageKeyType
|
True
|
StorageKeyType
|
Typ av lagringsnyckel: StorageAccessKey, SharedAccessKey eller ManagedIdentity.
|
|
storageUri
|
True
|
string
|
Lagrings-URI.
|
|
administratorLoginPassword
|
|
string
(password)
|
Administratörens inloggningslösenord. Om AuthenticationType är ManagedIdentity ska det här fältet inte anges.
|
|
authenticationType
|
|
string
|
Typ av autentiseringsuppgifter som tillhandahålls för åtkomst till SQL-målservern: SQL, ADPassword eller ManagedIdentity.
|
|
networkIsolation
|
|
NetworkIsolationSettings
|
Valfri resursinformation för att aktivera nätverksisolering för begäran.
|
Svar
| Name |
Typ |
Description |
|
200 OK
|
ImportExportOperationResult
|
Azure-operationen slutfördes framgångsrikt.
|
|
202 Accepted
|
|
Resursåtgärden har godkänts.
Sidhuvuden
- Location: string
- Retry-After: integer
|
|
Other Status Codes
|
ErrorResponse
|
Ett oväntat felsvar.
|
Säkerhet
azure_auth
Azure Active Directory OAuth2 Flow.
Typ:
oauth2
Flow:
implicit
Auktoriseringswebbadress:
https://login.microsoftonline.com/common/oauth2/authorize
Omfattningar
| Name |
Description |
|
user_impersonation
|
personifiera ditt användarkonto
|
Exempel
Imports to an existing empty database, using Managed Identity to communicate with SQL server and storage account.
Exempelbegäran
POST https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb/import?api-version=2025-01-01
{
"administratorLogin": "/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/rgName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityName",
"authenticationType": "ManagedIdentity",
"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.ImportExistingDatabaseDefinition;
import com.azure.resourcemanager.sql.models.StorageKeyType;
/**
* Samples for Databases ImportMethod.
*/
public final class Main {
/*
* x-ms-original-file: 2025-01-01/ImportDatabaseWithManagedIdentity.json
*/
/**
* Sample code: Imports to an existing empty database, using Managed Identity to communicate with SQL server and
* storage account.
*
* @param manager Entry point to SqlServerManager.
*/
public static void importsToAnExistingEmptyDatabaseUsingManagedIdentityToCommunicateWithSQLServerAndStorageAccount(
com.azure.resourcemanager.sql.SqlServerManager manager) {
manager.serviceClient().getDatabases().importMethod("Default-SQL-SouthEastAsia", "testsvr", "testdb",
new ImportExistingDatabaseDefinition().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_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.databases.begin_import_method(
resource_group_name="Default-SQL-SouthEastAsia",
server_name="testsvr",
database_name="testdb",
parameters={
"administratorLogin": "/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/rgName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityName",
"authenticationType": "ManagedIdentity",
"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/ImportDatabaseWithManagedIdentity.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/ImportDatabaseWithManagedIdentity.json
*/
async function importsToAnExistingEmptyDatabaseUsingManagedIdentityToCommunicateWithSQLServerAndStorageAccount() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.databases.import("Default-SQL-SouthEastAsia", "testsvr", "testdb", {
administratorLogin:
"/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/rgName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityName",
authenticationType: "ManagedIdentity",
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.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/ImportDatabaseWithManagedIdentity.json
// this example is just showing the usage of "Databases_Import" 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 = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string serverName = "testsvr";
string databaseName = "testdb";
ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName);
SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId);
// invoke the operation
ImportExistingDatabaseDefinition importExistingDatabaseDefinition = new ImportExistingDatabaseDefinition(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")
{
AuthenticationType = "ManagedIdentity",
};
ArmOperation<ImportExportOperationResult> lro = await sqlDatabase.ImportAsync(WaitUntil.Completed, importExistingDatabaseDefinition);
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
Exempelsvar
{
"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: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Sql/locations/japaneast/importExportOperationResults/00000000-0000-0000-0000-000000000000
Imports to an existing empty database, using private link to communicate with SQL server and storage account.
Exempelbegäran
POST https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb/import?api-version=2025-01-01
{
"administratorLogin": "login",
"administratorLoginPassword": "password",
"authenticationType": "Sql",
"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.ImportExistingDatabaseDefinition;
import com.azure.resourcemanager.sql.models.NetworkIsolationSettings;
import com.azure.resourcemanager.sql.models.StorageKeyType;
/**
* Samples for Databases ImportMethod.
*/
public final class Main {
/*
* x-ms-original-file: 2025-01-01/ImportDatabaseWithNetworkIsolation.json
*/
/**
* Sample code: Imports to an existing empty database, using private link to communicate with SQL server and storage
* account.
*
* @param manager Entry point to SqlServerManager.
*/
public static void importsToAnExistingEmptyDatabaseUsingPrivateLinkToCommunicateWithSQLServerAndStorageAccount(
com.azure.resourcemanager.sql.SqlServerManager manager) {
manager.serviceClient().getDatabases().importMethod("Default-SQL-SouthEastAsia", "testsvr", "testdb",
new ImportExistingDatabaseDefinition().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_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.databases.begin_import_method(
resource_group_name="Default-SQL-SouthEastAsia",
server_name="testsvr",
database_name="testdb",
parameters={
"administratorLogin": "login",
"administratorLoginPassword": "password",
"authenticationType": "Sql",
"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/ImportDatabaseWithNetworkIsolation.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/ImportDatabaseWithNetworkIsolation.json
*/
async function importsToAnExistingEmptyDatabaseUsingPrivateLinkToCommunicateWithSQLServerAndStorageAccount() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.databases.import("Default-SQL-SouthEastAsia", "testsvr", "testdb", {
administratorLogin: "login",
administratorLoginPassword: "password",
authenticationType: "Sql",
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.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/ImportDatabaseWithNetworkIsolation.json
// this example is just showing the usage of "Databases_Import" 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 = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string serverName = "testsvr";
string databaseName = "testdb";
ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName);
SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId);
// invoke the operation
ImportExistingDatabaseDefinition importExistingDatabaseDefinition = new ImportExistingDatabaseDefinition(StorageKeyType.StorageAccessKey, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==", new Uri("https://test.blob.core.windows.net/test.bacpac"), "login")
{
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 sqlDatabase.ImportAsync(WaitUntil.Completed, importExistingDatabaseDefinition);
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
Exempelsvar
{
"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: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Sql/locations/japaneast/importExportOperationResults/00000000-0000-0000-0000-000000000000
Imports to an existing empty database.
Exempelbegäran
POST https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb/import?api-version=2025-01-01
{
"administratorLogin": "login",
"administratorLoginPassword": "password",
"authenticationType": "Sql",
"storageKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==",
"storageKeyType": "StorageAccessKey",
"storageUri": "https://test.blob.core.windows.net/test.bacpac"
}
import com.azure.resourcemanager.sql.models.ImportExistingDatabaseDefinition;
import com.azure.resourcemanager.sql.models.StorageKeyType;
/**
* Samples for Databases ImportMethod.
*/
public final class Main {
/*
* x-ms-original-file: 2025-01-01/ImportDatabase.json
*/
/**
* Sample code: Imports to an existing empty database.
*
* @param manager Entry point to SqlServerManager.
*/
public static void importsToAnExistingEmptyDatabase(com.azure.resourcemanager.sql.SqlServerManager manager) {
manager.serviceClient().getDatabases().importMethod("Default-SQL-SouthEastAsia", "testsvr", "testdb",
new ImportExistingDatabaseDefinition().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_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.databases.begin_import_method(
resource_group_name="Default-SQL-SouthEastAsia",
server_name="testsvr",
database_name="testdb",
parameters={
"administratorLogin": "login",
"administratorLoginPassword": "password",
"authenticationType": "Sql",
"storageKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==",
"storageKeyType": "StorageAccessKey",
"storageUri": "https://test.blob.core.windows.net/test.bacpac",
},
).result()
print(response)
# x-ms-original-file: 2025-01-01/ImportDatabase.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/ImportDatabase.json
*/
async function importsToAnExistingEmptyDatabase() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.databases.import("Default-SQL-SouthEastAsia", "testsvr", "testdb", {
administratorLogin: "login",
administratorLoginPassword: "password",
authenticationType: "Sql",
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.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/ImportDatabase.json
// this example is just showing the usage of "Databases_Import" 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 = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string serverName = "testsvr";
string databaseName = "testdb";
ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName);
SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId);
// invoke the operation
ImportExistingDatabaseDefinition importExistingDatabaseDefinition = new ImportExistingDatabaseDefinition(StorageKeyType.StorageAccessKey, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==", new Uri("https://test.blob.core.windows.net/test.bacpac"), "login")
{
AdministratorLoginPassword = "password",
AuthenticationType = "Sql",
};
ArmOperation<ImportExportOperationResult> lro = await sqlDatabase.ImportAsync(WaitUntil.Completed, importExistingDatabaseDefinition);
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
Exempelsvar
{
"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: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Sql/locations/japaneast/importExportOperationResults/00000000-0000-0000-0000-000000000000
Definitioner
createdByType
Uppräkning
Den typ av identitet som skapade resursen.
| Värde |
Description |
|
User
|
|
|
Application
|
|
|
ManagedIdentity
|
|
|
Key
|
|
ErrorAdditionalInfo
Objekt
Resurshanteringsfelet ytterligare information.
| Name |
Typ |
Description |
|
info
|
object
|
Den ytterligare informationen.
|
|
type
|
string
|
Typen av ytterligare information.
|
ErrorDetail
Objekt
Detaljerna om felet.
| Name |
Typ |
Description |
|
additionalInfo
|
ErrorAdditionalInfo[]
|
Felet ytterligare information.
|
|
code
|
string
|
Felkoden.
|
|
details
|
ErrorDetail[]
|
Felinformationen.
|
|
message
|
string
|
Felmeddelandet.
|
|
target
|
string
|
Felmålet.
|
ErrorResponse
Objekt
Felsvar
ImportExistingDatabaseDefinition
Objekt
Innehåller den information som krävs för att utföra importåtgärden för en befintlig databas.
| Name |
Typ |
Description |
|
administratorLogin
|
string
|
Administratörens inloggningsnamn. Om AuthenticationType är ManagedIdentity ska det här fältet ange den hanterade identitetens resurs-ID.
|
|
administratorLoginPassword
|
string
(password)
|
Administratörens inloggningslösenord. Om AuthenticationType är ManagedIdentity ska det här fältet inte anges.
|
|
authenticationType
|
string
|
Typ av autentiseringsuppgifter som tillhandahålls för åtkomst till SQL-målservern: SQL, ADPassword eller ManagedIdentity.
|
|
networkIsolation
|
NetworkIsolationSettings
|
Valfri resursinformation för att aktivera nätverksisolering för begäran.
|
|
storageKey
|
string
|
Lagringsnyckel för lagringskontot. Om StorageKeyType är ManagedIdentity ska det här fältet ange den hanterade identitetens resurs-ID.
|
|
storageKeyType
|
StorageKeyType
|
Typ av lagringsnyckel: StorageAccessKey, SharedAccessKey eller ManagedIdentity.
|
|
storageUri
|
string
|
Lagrings-URI.
|
ImportExportOperationResult
Objekt
En resultatresurs för ImportExport-åtgärden.
| Name |
Typ |
Description |
|
id
|
string
(arm-id)
|
Fullständigt kvalificerat resurs-ID för resursen. T.ex. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"
|
|
name
|
string
|
Namnet på resursen
|
|
properties.blobUri
|
string
|
Blob-URI.
|
|
properties.databaseName
|
string
|
Databasnamn.
|
|
properties.errorMessage
|
string
|
Felmeddelande.
|
|
properties.lastModifiedTime
|
string
|
Senast ändrad tid.
|
|
properties.privateEndpointConnections
|
PrivateEndpointConnectionRequestStatus[]
|
Hämtar status för privata slutpunkter som är associerade med den här begäran.
|
|
properties.queuedTime
|
string
|
Köad tid.
|
|
properties.requestId
|
string
(uuid)
|
Begärande-ID.
|
|
properties.requestType
|
string
|
Typ av begäran.
|
|
properties.serverName
|
string
|
Servernamn.
|
|
properties.status
|
string
|
Åtgärdsstatus.
|
|
systemData
|
systemData
|
Azure Resource Manager-metadata som innehåller creationBy och modifiedBy-information.
|
|
type
|
string
|
Resurstypen. T.ex. "Microsoft. Compute/virtualMachines" eller "Microsoft. Storage/storageAccounts"
|
NetworkIsolationSettings
Objekt
Innehåller DE ARM-resurser som du vill skapa en privat slutpunktsanslutning för.
| Name |
Typ |
Description |
|
sqlServerResourceId
|
string
(arm-id)
|
Resurs-ID:t för SQL-servern som är målet för den här begäran. Om den anges skapas en privat slutpunktsanslutning för SQL-servern. Måste matcha servern som är målet för åtgärden.
|
|
storageAccountResourceId
|
string
(arm-id)
|
Resurs-ID:t för lagringskontot som används för att lagra BACPAC-filen. Om det anges skapas en privat slutpunktsanslutning för lagringskontot. Måste matcha lagringskontot som används för parametern StorageUri.
|
PrivateEndpointConnectionRequestStatus
Objekt
Innehåller status för privata slutpunktsanslutningsbegäranden.
| Name |
Typ |
Description |
|
privateEndpointConnectionName
|
string
|
Anslutningsnamnet för den privata slutpunkten.
|
|
privateLinkServiceId
|
string
|
Resurs-ID som den privata slutpunkten skapas för.
|
|
status
|
string
|
Status för den här privata slutpunktsanslutningen.
|
StorageKeyType
Uppräkning
Typ av lagringsnyckel: StorageAccessKey, SharedAccessKey eller ManagedIdentity.
| Värde |
Description |
|
SharedAccessKey
|
SharedAccessKey
|
|
StorageAccessKey
|
StorageAccessKey
|
|
ManagedIdentity
|
ManagedIdentity
|
systemData
Objekt
Metadata som rör skapande och senaste ändring av resursen.
| Name |
Typ |
Description |
|
createdAt
|
string
(date-time)
|
Tidsstämpeln för resursskapande (UTC).
|
|
createdBy
|
string
|
Identiteten som skapade resursen.
|
|
createdByType
|
createdByType
|
Den typ av identitet som skapade resursen.
|
|
lastModifiedAt
|
string
(date-time)
|
Tidsstämpeln för senaste ändring av resurs (UTC)
|
|
lastModifiedBy
|
string
|
Identiteten som senast ändrade resursen.
|
|
lastModifiedByType
|
createdByType
|
Den typ av identitet som senast ändrade resursen.
|