diff --git a/src/command_modules/azure-cli-sql/azure/cli/command_modules/sql/commands.py b/src/command_modules/azure-cli-sql/azure/cli/command_modules/sql/commands.py index e7d524504a3..6b287254e76 100644 --- a/src/command_modules/azure-cli-sql/azure/cli/command_modules/sql/commands.py +++ b/src/command_modules/azure-cli-sql/azure/cli/command_modules/sql/commands.py @@ -24,6 +24,8 @@ # c.command('show-usage', 'list_usages') c.command('delete', 'delete', confirmation=True) c.generic_update_command('update', 'get', 'create_or_update', custom_func_name='db_update') + c.command('import', 'import_method') + c.command('export', 'export') with s.group('sql db replica') as c: c.custom_command('create', 'db_create_replica') @@ -99,6 +101,7 @@ 'ServersOperations') with ServiceGroup(__name__, get_sql_servers_operation, server_operations) as s: + with s.group('sql server') as c: c.command('create', 'create_or_update') c.command('delete', 'delete', confirmation=True) diff --git a/src/command_modules/azure-cli-sql/azure/cli/command_modules/sql/help.py b/src/command_modules/azure-cli-sql/azure/cli/command_modules/sql/help.py index 370353a355c..382ea39f3a3 100644 --- a/src/command_modules/azure-cli-sql/azure/cli/command_modules/sql/help.py +++ b/src/command_modules/azure-cli-sql/azure/cli/command_modules/sql/help.py @@ -63,6 +63,10 @@ type: command short-summary: Creates a new database by restoring from a database backup. """ +helps['sql db import'] = """ + type: command + short-summary: Imports a bacpac into an existing database. + """ # helps['sql db restore-point'] = """ # type: group # short-summary: Manage database restore points. diff --git a/src/command_modules/azure-cli-sql/azure/cli/command_modules/sql/params.py b/src/command_modules/azure-cli-sql/azure/cli/command_modules/sql/params.py index 35698eff0bc..0bcccabe575 100644 --- a/src/command_modules/azure-cli-sql/azure/cli/command_modules/sql/params.py +++ b/src/command_modules/azure-cli-sql/azure/cli/command_modules/sql/params.py @@ -7,10 +7,17 @@ from enum import Enum from ._util import ParametersContext, patch_arg_make_required from azure.cli.core.commands import CliArgumentType +from azure.cli.core.commands.parameters import enum_choice_list +from azure.cli.core.commands.parameters import ignore_type from azure.mgmt.sql.models.database import Database from azure.mgmt.sql.models.elastic_pool import ElasticPool from azure.mgmt.sql.models.server import Server +from azure.mgmt.sql.models.import_extension_request_parameters \ + import ImportExtensionRequestParameters +from azure.mgmt.sql.models.export_request_parameters import ExportRequestParameters from azure.mgmt.sql.models.sql_management_client_enums import CreateMode +from azure.mgmt.sql.models.sql_management_client_enums import StorageKeyType +from azure.mgmt.sql.models.sql_management_client_enums import AuthenticationType ##### # Reusable param type definitions @@ -21,7 +28,6 @@ options_list=('--server', '-s'), help='Name of the Azure SQL server.') - ##### # SizeWithUnitConverter - consider moving to common code (azure.cli.commands.parameters) ##### @@ -261,6 +267,23 @@ def _configure_db_create_params( c.argument('elastic_pool_name', help='The name of the elastic pool to move the database into.') c.argument('max_size_bytes', help='The new maximum size of the database expressed in bytes.') +with ParametersContext(command='sql db export') as c: + c.expand('parameters', ExportRequestParameters) + c.register_alias('administrator_login', ('--admin-user', '-u')) + c.register_alias('administrator_login_password', ('--admin-password', '-p')) + c.argument('authentication_type', options_list=('--auth_type',), + **enum_choice_list(AuthenticationType)) + c.argument('storage_key_type', **enum_choice_list(StorageKeyType)) + +with ParametersContext(command='sql db import') as c: + c.expand('parameters', ImportExtensionRequestParameters) + c.register_alias('administrator_login', ('--admin-user', '-u')) + c.register_alias('administrator_login_password', ('--admin-password', '-p')) + c.argument('authentication_type', options_list=('--auth_type',), + **enum_choice_list(AuthenticationType)) + c.argument('storage_key_type', **enum_choice_list(StorageKeyType)) + c.argument('name', options_list=('--slkdjflksdjf',), arg_type=ignore_type) + ##### # sql db replica diff --git a/src/command_modules/azure-cli-sql/setup.py b/src/command_modules/azure-cli-sql/setup.py index 515833d79a7..24515972d86 100644 --- a/src/command_modules/azure-cli-sql/setup.py +++ b/src/command_modules/azure-cli-sql/setup.py @@ -24,7 +24,7 @@ DEPENDENCIES = [ 'azure-cli-core', - 'azure-mgmt-sql==0.3.1', + 'azure-mgmt-sql==0.3.2', 'six' ] diff --git a/src/command_modules/azure-cli-sql/tests/recordings/test_sql_db_import_export_mgmt.yaml b/src/command_modules/azure-cli-sql/tests/recordings/test_sql_db_import_export_mgmt.yaml new file mode 100644 index 00000000000..df6194f639f --- /dev/null +++ b/src/command_modules/azure-cli-sql/tests/recordings/test_sql_db_import_export_mgmt.yaml @@ -0,0 +1,976 @@ +interactions: +- request: + body: '{"location": "westus", "tags": {"use": "az-test"}}' + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [group create] + Connection: [keep-alive] + Content-Length: ['50'] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.5.3 (Windows-2012ServerR2-6.3.9600-SP0) requests/2.9.1 + msrest/0.4.4 msrest_azure/0.4.7 resourcemanagementclient/0.30.2 Azure-SDK-For-Python + AZURECLI/2.0.1+dev] + accept-language: [en-US] + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/clitest.rg000001?api-version=2016-09-01 + response: + body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001","name":"clitest.rg000001","location":"westus","tags":{"use":"az-test"},"properties":{"provisioningState":"Succeeded"}}'} + headers: + cache-control: [no-cache] + content-length: ['326'] + content-type: [application/json; charset=utf-8] + date: ['Fri, 17 Mar 2017 00:30:00 GMT'] + expires: ['-1'] + pragma: [no-cache] + strict-transport-security: [max-age=31536000; includeSubDomains] + x-ms-ratelimit-remaining-subscription-writes: ['1197'] + status: {code: 201, message: Created} +- request: + body: '{"location": "westus", "properties": {"administratorLogin": "admin123", + "administratorLoginPassword": "SecretPassword123"}}' + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [sql server create] + Connection: [keep-alive] + Content-Length: ['123'] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.5.3 (Windows-2012ServerR2-6.3.9600-SP0) requests/2.9.1 + msrest/0.4.4 msrest_azure/0.4.7 sqlmanagementclient/0.3.2 Azure-SDK-For-Python + AZURECLI/2.0.1+dev] + accept-language: [en-US] + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002?api-version=2014-04-01 + response: + body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002","name":"clitestserver000002","type":"Microsoft.Sql/servers","location":"West + US","kind":"v12.0","properties":{"fullyQualifiedDomainName":"clitestserver000002.database.windows.net","administratorLogin":"admin123","administratorLoginPassword":"SecretPassword123","externalAdministratorLogin":null,"externalAdministratorSid":null,"version":"12.0","state":"Ready"}}'} + headers: + cache-control: ['no-store, no-cache'] + content-length: ['695'] + content-type: [application/json; odata=minimalmetadata; streaming=true; charset=utf-8] + dataserviceversion: [3.0;] + date: ['Fri, 17 Mar 2017 00:30:39 GMT'] + preference-applied: [return-content] + server: [Microsoft-HTTPAPI/2.0] + strict-transport-security: [max-age=31536000; includeSubDomains] + x-content-type-options: [nosniff] + x-ms-ratelimit-remaining-subscription-writes: ['1198'] + status: {code: 201, message: Created} +- request: + body: '{"location": "westus", "sku": {"name": "Standard_LRS"}, "kind": "Storage"}' + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [storage account create] + Connection: [keep-alive] + Content-Length: ['74'] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.5.3 (Windows-2012ServerR2-6.3.9600-SP0) requests/2.9.1 + msrest/0.4.4 msrest_azure/0.4.7 storagemanagementclient/0.31.0 Azure-SDK-For-Python + AZURECLI/2.0.1+dev] + accept-language: [en-US] + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/clitest000003?api-version=2016-12-01 + response: + body: {string: ''} + headers: + cache-control: [no-cache] + content-length: ['0'] + date: ['Fri, 17 Mar 2017 00:30:47 GMT'] + expires: ['-1'] + location: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Storage/operations/5ebbaa81-3475-45a7-8924-25343dc11908?monitor=true&api-version=2016-12-01'] + pragma: [no-cache] + retry-after: ['17'] + server: [Microsoft-Azure-Storage-Resource-Provider/1.0, Microsoft-HTTPAPI/2.0] + strict-transport-security: [max-age=31536000; includeSubDomains] + x-ms-ratelimit-remaining-subscription-writes: ['1196'] + status: {code: 202, message: Accepted} +- request: + body: null + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [storage account create] + Connection: [keep-alive] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.5.3 (Windows-2012ServerR2-6.3.9600-SP0) requests/2.9.1 + msrest/0.4.4 msrest_azure/0.4.7 storagemanagementclient/0.31.0 Azure-SDK-For-Python + AZURECLI/2.0.1+dev] + accept-language: [en-US] + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Storage/operations/5ebbaa81-3475-45a7-8924-25343dc11908?monitor=true&api-version=2016-12-01 + response: + body: {string: ''} + headers: + cache-control: [no-cache] + content-length: ['0'] + date: ['Fri, 17 Mar 2017 00:31:04 GMT'] + expires: ['-1'] + location: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Storage/operations/5ebbaa81-3475-45a7-8924-25343dc11908?monitor=true&api-version=2016-12-01'] + pragma: [no-cache] + retry-after: ['17'] + server: [Microsoft-Azure-Storage-Resource-Provider/1.0, Microsoft-HTTPAPI/2.0] + strict-transport-security: [max-age=31536000; includeSubDomains] + status: {code: 202, message: Accepted} +- request: + body: null + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [storage account create] + Connection: [keep-alive] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.5.3 (Windows-2012ServerR2-6.3.9600-SP0) requests/2.9.1 + msrest/0.4.4 msrest_azure/0.4.7 storagemanagementclient/0.31.0 Azure-SDK-For-Python + AZURECLI/2.0.1+dev] + accept-language: [en-US] + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Storage/operations/5ebbaa81-3475-45a7-8924-25343dc11908?monitor=true&api-version=2016-12-01 + response: + body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/clitest000003","kind":"Storage","location":"westus","name":"clitest000003","properties":{"creationTime":"2017-03-17T00:30:41.9704294Z","primaryEndpoints":{"blob":"https://clitest000003.blob.core.windows.net/","file":"https://clitest000003.file.core.windows.net/","queue":"https://clitest000003.queue.core.windows.net/","table":"https://clitest000003.table.core.windows.net/"},"primaryLocation":"westus","provisioningState":"Succeeded","statusOfPrimary":"available"},"sku":{"name":"Standard_LRS","tier":"Standard"},"tags":{},"type":"Microsoft.Storage/storageAccounts"} + + '} + headers: + cache-control: [no-cache] + content-length: ['827'] + content-type: [application/json] + date: ['Fri, 17 Mar 2017 00:31:22 GMT'] + expires: ['-1'] + pragma: [no-cache] + server: [Microsoft-Azure-Storage-Resource-Provider/1.0, Microsoft-HTTPAPI/2.0] + strict-transport-security: [max-age=31536000; includeSubDomains] + transfer-encoding: [chunked] + vary: [Accept-Encoding] + status: {code: 200, message: OK} +- request: + body: '{"properties": {"startIpAddress": "0.0.0.0", "endIpAddress": "255.255.255.255"}}' + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [sql server firewall-rule create] + Connection: [keep-alive] + Content-Length: ['80'] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.5.3 (Windows-2012ServerR2-6.3.9600-SP0) requests/2.9.1 + msrest/0.4.4 msrest_azure/0.4.7 sqlmanagementclient/0.3.2 Azure-SDK-For-Python + AZURECLI/2.0.1+dev] + accept-language: [en-US] + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/firewallRules/allowAllIps?api-version=2014-04-01 + response: + body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/firewallRules/allowAllIps","name":"allowAllIps","type":"Microsoft.Sql/servers/firewallRules","location":"West + US","kind":"v12.0","properties":{"startIpAddress":"0.0.0.0","endIpAddress":"255.255.255.255"}}'} + headers: + cache-control: ['no-store, no-cache'] + content-length: ['449'] + content-type: [application/json; odata=minimalmetadata; streaming=true; charset=utf-8] + dataserviceversion: [3.0;] + date: ['Fri, 17 Mar 2017 00:31:24 GMT'] + preference-applied: [return-content] + server: [Microsoft-HTTPAPI/2.0] + strict-transport-security: [max-age=31536000; includeSubDomains] + x-content-type-options: [nosniff] + x-ms-ratelimit-remaining-subscription-writes: ['1198'] + status: {code: 201, message: Created} +- request: + body: null + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [sql db create] + Connection: [keep-alive] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.5.3 (Windows-2012ServerR2-6.3.9600-SP0) requests/2.9.1 + msrest/0.4.4 msrest_azure/0.4.7 sqlmanagementclient/0.3.2 Azure-SDK-For-Python + AZURECLI/2.0.1+dev] + accept-language: [en-US] + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002?api-version=2014-04-01 + response: + body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002","name":"clitestserver000002","type":"Microsoft.Sql/servers","location":"West + US","kind":"v12.0","properties":{"fullyQualifiedDomainName":"clitestserver000002.database.windows.net","administratorLogin":"admin123","administratorLoginPassword":null,"externalAdministratorLogin":null,"externalAdministratorSid":null,"version":"12.0","state":"Ready"}}'} + headers: + cache-control: ['no-store, no-cache'] + content-length: ['680'] + content-type: [application/json; odata=minimalmetadata; streaming=true; charset=utf-8] + dataserviceversion: [3.0;] + date: ['Fri, 17 Mar 2017 00:31:26 GMT'] + server: [Microsoft-HTTPAPI/2.0] + strict-transport-security: [max-age=31536000; includeSubDomains] + transfer-encoding: [chunked] + vary: [Accept-Encoding] + x-content-type-options: [nosniff] + status: {code: 200, message: OK} +- request: + body: '{"location": "West US"}' + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [sql db create] + Connection: [keep-alive] + Content-Length: ['23'] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.5.3 (Windows-2012ServerR2-6.3.9600-SP0) requests/2.9.1 + msrest/0.4.4 msrest_azure/0.4.7 sqlmanagementclient/0.3.2 Azure-SDK-For-Python + AZURECLI/2.0.1+dev] + accept-language: [en-US] + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb01?api-version=2014-04-01 + response: + body: {string: '{"operation":"CreateLogicalDatabase","startTime":"\/Date(1489710687916+0000)\/"}'} + headers: + azure-asyncoperation: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb01/azureAsyncOperation/17714879-cc06-48b6-b379-e3f2942853b4?api-version=2014-04-01-Preview'] + cache-control: ['no-store, no-cache'] + content-length: ['80'] + content-type: [application/json; odata=minimalmetadata; streaming=true; charset=utf-8] + dataserviceversion: [3.0;] + date: ['Fri, 17 Mar 2017 00:31:28 GMT'] + location: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb01/operationResults/17714879-cc06-48b6-b379-e3f2942853b4?api-version=2014-04-01-Preview'] + preference-applied: [return-content] + retry-after: ['30'] + server: [Microsoft-HTTPAPI/2.0] + strict-transport-security: [max-age=31536000; includeSubDomains] + x-content-type-options: [nosniff] + x-ms-ratelimit-remaining-subscription-writes: ['1194'] + status: {code: 202, message: Accepted} +- request: + body: null + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [sql db create] + Connection: [keep-alive] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.5.3 (Windows-2012ServerR2-6.3.9600-SP0) requests/2.9.1 + msrest/0.4.4 msrest_azure/0.4.7 sqlmanagementclient/0.3.2 Azure-SDK-For-Python + AZURECLI/2.0.1+dev] + accept-language: [en-US] + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb01/azureAsyncOperation/17714879-cc06-48b6-b379-e3f2942853b4?api-version=2014-04-01-Preview + response: + body: {string: '{"operationId":"17714879-cc06-48b6-b379-e3f2942853b4","status":"InProgress","error":null}'} + headers: + azure-asyncoperation: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb01/azureAsyncOperation/17714879-cc06-48b6-b379-e3f2942853b4?api-version=2014-04-01-Preview'] + cache-control: ['no-store, no-cache'] + content-length: ['89'] + content-type: [application/json; odata=minimalmetadata; streaming=true; charset=utf-8] + dataserviceversion: [3.0;] + date: ['Fri, 17 Mar 2017 00:32:04 GMT'] + server: [Microsoft-HTTPAPI/2.0] + strict-transport-security: [max-age=31536000; includeSubDomains] + transfer-encoding: [chunked] + vary: [Accept-Encoding] + x-content-type-options: [nosniff] + status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [sql db create] + Connection: [keep-alive] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.5.3 (Windows-2012ServerR2-6.3.9600-SP0) requests/2.9.1 + msrest/0.4.4 msrest_azure/0.4.7 sqlmanagementclient/0.3.2 Azure-SDK-For-Python + AZURECLI/2.0.1+dev] + accept-language: [en-US] + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb01/azureAsyncOperation/17714879-cc06-48b6-b379-e3f2942853b4?api-version=2014-04-01-Preview + response: + body: {string: '{"operationId":"17714879-cc06-48b6-b379-e3f2942853b4","status":"InProgress","error":null}'} + headers: + azure-asyncoperation: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb01/azureAsyncOperation/17714879-cc06-48b6-b379-e3f2942853b4?api-version=2014-04-01-Preview'] + cache-control: ['no-store, no-cache'] + content-length: ['89'] + content-type: [application/json; odata=minimalmetadata; streaming=true; charset=utf-8] + dataserviceversion: [3.0;] + date: ['Fri, 17 Mar 2017 00:32:35 GMT'] + server: [Microsoft-HTTPAPI/2.0] + strict-transport-security: [max-age=31536000; includeSubDomains] + transfer-encoding: [chunked] + vary: [Accept-Encoding] + x-content-type-options: [nosniff] + status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [sql db create] + Connection: [keep-alive] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.5.3 (Windows-2012ServerR2-6.3.9600-SP0) requests/2.9.1 + msrest/0.4.4 msrest_azure/0.4.7 sqlmanagementclient/0.3.2 Azure-SDK-For-Python + AZURECLI/2.0.1+dev] + accept-language: [en-US] + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb01/azureAsyncOperation/17714879-cc06-48b6-b379-e3f2942853b4?api-version=2014-04-01-Preview + response: + body: {string: '{"operationId":"17714879-cc06-48b6-b379-e3f2942853b4","status":"InProgress","error":null}'} + headers: + azure-asyncoperation: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb01/azureAsyncOperation/17714879-cc06-48b6-b379-e3f2942853b4?api-version=2014-04-01-Preview'] + cache-control: ['no-store, no-cache'] + content-length: ['89'] + content-type: [application/json; odata=minimalmetadata; streaming=true; charset=utf-8] + dataserviceversion: [3.0;] + date: ['Fri, 17 Mar 2017 00:33:06 GMT'] + server: [Microsoft-HTTPAPI/2.0] + strict-transport-security: [max-age=31536000; includeSubDomains] + transfer-encoding: [chunked] + vary: [Accept-Encoding] + x-content-type-options: [nosniff] + status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [sql db create] + Connection: [keep-alive] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.5.3 (Windows-2012ServerR2-6.3.9600-SP0) requests/2.9.1 + msrest/0.4.4 msrest_azure/0.4.7 sqlmanagementclient/0.3.2 Azure-SDK-For-Python + AZURECLI/2.0.1+dev] + accept-language: [en-US] + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb01/azureAsyncOperation/17714879-cc06-48b6-b379-e3f2942853b4?api-version=2014-04-01-Preview + response: + body: {string: '{"operationId":"17714879-cc06-48b6-b379-e3f2942853b4","status":"Succeeded","error":null}'} + headers: + azure-asyncoperation: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb01/azureAsyncOperation/17714879-cc06-48b6-b379-e3f2942853b4?api-version=2014-04-01-Preview'] + cache-control: ['no-store, no-cache'] + content-length: ['88'] + content-type: [application/json; odata=minimalmetadata; streaming=true; charset=utf-8] + dataserviceversion: [3.0;] + date: ['Fri, 17 Mar 2017 00:33:37 GMT'] + server: [Microsoft-HTTPAPI/2.0] + strict-transport-security: [max-age=31536000; includeSubDomains] + transfer-encoding: [chunked] + vary: [Accept-Encoding] + x-content-type-options: [nosniff] + status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [sql db create] + Connection: [keep-alive] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.5.3 (Windows-2012ServerR2-6.3.9600-SP0) requests/2.9.1 + msrest/0.4.4 msrest_azure/0.4.7 sqlmanagementclient/0.3.2 Azure-SDK-For-Python + AZURECLI/2.0.1+dev] + accept-language: [en-US] + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb01?api-version=2014-04-01 + response: + body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb01","name":"cliautomationdb01","type":"Microsoft.Sql/servers/databases","location":"West + US","kind":"v12.0,user","properties":{"databaseId":"faf90da1-59ef-4f5c-afa2-2f4e96f5a416","edition":"Standard","status":"Online","serviceLevelObjective":"S0","collation":"SQL_Latin1_General_CP1_CI_AS","maxSizeBytes":"268435456000","creationDate":"2017-03-17T00:31:28.12Z","currentServiceObjectiveId":"f1173c43-91bd-4aaa-973c-54e79e15235b","requestedServiceObjectiveId":"f1173c43-91bd-4aaa-973c-54e79e15235b","requestedServiceObjectiveName":"S0","sampleName":null,"defaultSecondaryLocation":"East + US","earliestRestoreDate":"2017-03-17T00:43:27.713Z","elasticPoolName":null,"containmentState":2,"readScale":"Disabled","failoverGroupId":null}}'} + headers: + cache-control: ['no-store, no-cache'] + content-length: ['999'] + content-type: [application/json; odata=minimalmetadata; streaming=true; charset=utf-8] + dataserviceversion: [3.0;] + date: ['Fri, 17 Mar 2017 00:33:39 GMT'] + server: [Microsoft-HTTPAPI/2.0] + strict-transport-security: [max-age=31536000; includeSubDomains] + transfer-encoding: [chunked] + vary: [Accept-Encoding] + x-content-type-options: [nosniff] + status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [sql db create] + Connection: [keep-alive] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.5.3 (Windows-2012ServerR2-6.3.9600-SP0) requests/2.9.1 + msrest/0.4.4 msrest_azure/0.4.7 sqlmanagementclient/0.3.2 Azure-SDK-For-Python + AZURECLI/2.0.1+dev] + accept-language: [en-US] + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002?api-version=2014-04-01 + response: + body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002","name":"clitestserver000002","type":"Microsoft.Sql/servers","location":"West + US","kind":"v12.0","properties":{"fullyQualifiedDomainName":"clitestserver000002.database.windows.net","administratorLogin":"admin123","administratorLoginPassword":null,"externalAdministratorLogin":null,"externalAdministratorSid":null,"version":"12.0","state":"Ready"}}'} + headers: + cache-control: ['no-store, no-cache'] + content-length: ['680'] + content-type: [application/json; odata=minimalmetadata; streaming=true; charset=utf-8] + dataserviceversion: [3.0;] + date: ['Fri, 17 Mar 2017 00:33:40 GMT'] + server: [Microsoft-HTTPAPI/2.0] + strict-transport-security: [max-age=31536000; includeSubDomains] + transfer-encoding: [chunked] + vary: [Accept-Encoding] + x-content-type-options: [nosniff] + status: {code: 200, message: OK} +- request: + body: '{"location": "West US"}' + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [sql db create] + Connection: [keep-alive] + Content-Length: ['23'] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.5.3 (Windows-2012ServerR2-6.3.9600-SP0) requests/2.9.1 + msrest/0.4.4 msrest_azure/0.4.7 sqlmanagementclient/0.3.2 Azure-SDK-For-Python + AZURECLI/2.0.1+dev] + accept-language: [en-US] + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb02?api-version=2014-04-01 + response: + body: {string: '{"operation":"CreateLogicalDatabase","startTime":"\/Date(1489710822417+0000)\/"}'} + headers: + azure-asyncoperation: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb02/azureAsyncOperation/53c4efcf-0f74-4935-9744-f17dfe97f707?api-version=2014-04-01-Preview'] + cache-control: ['no-store, no-cache'] + content-length: ['80'] + content-type: [application/json; odata=minimalmetadata; streaming=true; charset=utf-8] + dataserviceversion: [3.0;] + date: ['Fri, 17 Mar 2017 00:33:42 GMT'] + location: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb02/operationResults/53c4efcf-0f74-4935-9744-f17dfe97f707?api-version=2014-04-01-Preview'] + preference-applied: [return-content] + retry-after: ['30'] + server: [Microsoft-HTTPAPI/2.0] + strict-transport-security: [max-age=31536000; includeSubDomains] + x-content-type-options: [nosniff] + x-ms-ratelimit-remaining-subscription-writes: ['1199'] + status: {code: 202, message: Accepted} +- request: + body: null + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [sql db create] + Connection: [keep-alive] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.5.3 (Windows-2012ServerR2-6.3.9600-SP0) requests/2.9.1 + msrest/0.4.4 msrest_azure/0.4.7 sqlmanagementclient/0.3.2 Azure-SDK-For-Python + AZURECLI/2.0.1+dev] + accept-language: [en-US] + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb02/azureAsyncOperation/53c4efcf-0f74-4935-9744-f17dfe97f707?api-version=2014-04-01-Preview + response: + body: {string: '{"operationId":"53c4efcf-0f74-4935-9744-f17dfe97f707","status":"InProgress","error":null}'} + headers: + azure-asyncoperation: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb02/azureAsyncOperation/53c4efcf-0f74-4935-9744-f17dfe97f707?api-version=2014-04-01-Preview'] + cache-control: ['no-store, no-cache'] + content-length: ['89'] + content-type: [application/json; odata=minimalmetadata; streaming=true; charset=utf-8] + dataserviceversion: [3.0;] + date: ['Fri, 17 Mar 2017 00:34:14 GMT'] + server: [Microsoft-HTTPAPI/2.0] + strict-transport-security: [max-age=31536000; includeSubDomains] + transfer-encoding: [chunked] + vary: [Accept-Encoding] + x-content-type-options: [nosniff] + status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [sql db create] + Connection: [keep-alive] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.5.3 (Windows-2012ServerR2-6.3.9600-SP0) requests/2.9.1 + msrest/0.4.4 msrest_azure/0.4.7 sqlmanagementclient/0.3.2 Azure-SDK-For-Python + AZURECLI/2.0.1+dev] + accept-language: [en-US] + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb02/azureAsyncOperation/53c4efcf-0f74-4935-9744-f17dfe97f707?api-version=2014-04-01-Preview + response: + body: {string: '{"operationId":"53c4efcf-0f74-4935-9744-f17dfe97f707","status":"Succeeded","error":null}'} + headers: + azure-asyncoperation: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb02/azureAsyncOperation/53c4efcf-0f74-4935-9744-f17dfe97f707?api-version=2014-04-01-Preview'] + cache-control: ['no-store, no-cache'] + content-length: ['88'] + content-type: [application/json; odata=minimalmetadata; streaming=true; charset=utf-8] + dataserviceversion: [3.0;] + date: ['Fri, 17 Mar 2017 00:34:45 GMT'] + server: [Microsoft-HTTPAPI/2.0] + strict-transport-security: [max-age=31536000; includeSubDomains] + transfer-encoding: [chunked] + vary: [Accept-Encoding] + x-content-type-options: [nosniff] + status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [sql db create] + Connection: [keep-alive] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.5.3 (Windows-2012ServerR2-6.3.9600-SP0) requests/2.9.1 + msrest/0.4.4 msrest_azure/0.4.7 sqlmanagementclient/0.3.2 Azure-SDK-For-Python + AZURECLI/2.0.1+dev] + accept-language: [en-US] + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb02?api-version=2014-04-01 + response: + body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb02","name":"cliautomationdb02","type":"Microsoft.Sql/servers/databases","location":"West + US","kind":"v12.0,user","properties":{"databaseId":"97acfb28-004c-471a-abba-4d30b7fd16b6","edition":"Standard","status":"Online","serviceLevelObjective":"S0","collation":"SQL_Latin1_General_CP1_CI_AS","maxSizeBytes":"268435456000","creationDate":"2017-03-17T00:33:42.573Z","currentServiceObjectiveId":"f1173c43-91bd-4aaa-973c-54e79e15235b","requestedServiceObjectiveId":"f1173c43-91bd-4aaa-973c-54e79e15235b","requestedServiceObjectiveName":"S0","sampleName":null,"defaultSecondaryLocation":"East + US","earliestRestoreDate":"2017-03-17T00:44:14.653Z","elasticPoolName":null,"containmentState":2,"readScale":"Disabled","failoverGroupId":null}}'} + headers: + cache-control: ['no-store, no-cache'] + content-length: ['1000'] + content-type: [application/json; odata=minimalmetadata; streaming=true; charset=utf-8] + dataserviceversion: [3.0;] + date: ['Fri, 17 Mar 2017 00:34:46 GMT'] + server: [Microsoft-HTTPAPI/2.0] + strict-transport-security: [max-age=31536000; includeSubDomains] + transfer-encoding: [chunked] + vary: [Accept-Encoding] + x-content-type-options: [nosniff] + status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [storage account show] + Connection: [keep-alive] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.5.3 (Windows-2012ServerR2-6.3.9600-SP0) requests/2.9.1 + msrest/0.4.4 msrest_azure/0.4.7 storagemanagementclient/0.31.0 Azure-SDK-For-Python + AZURECLI/2.0.1+dev] + accept-language: [en-US] + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/clitest000003?api-version=2016-12-01 + response: + body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/clitest000003","kind":"Storage","location":"westus","name":"clitest000003","properties":{"creationTime":"2017-03-17T00:30:41.9704294Z","primaryEndpoints":{"blob":"https://clitest000003.blob.core.windows.net/","file":"https://clitest000003.file.core.windows.net/","queue":"https://clitest000003.queue.core.windows.net/","table":"https://clitest000003.table.core.windows.net/"},"primaryLocation":"westus","provisioningState":"Succeeded","statusOfPrimary":"available"},"sku":{"name":"Standard_LRS","tier":"Standard"},"tags":{},"type":"Microsoft.Storage/storageAccounts"} + + '} + headers: + cache-control: [no-cache] + content-length: ['827'] + content-type: [application/json] + date: ['Fri, 17 Mar 2017 00:34:48 GMT'] + expires: ['-1'] + pragma: [no-cache] + server: [Microsoft-Azure-Storage-Resource-Provider/1.0, Microsoft-HTTPAPI/2.0] + strict-transport-security: [max-age=31536000; includeSubDomains] + transfer-encoding: [chunked] + vary: [Accept-Encoding] + status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [storage account keys list] + Connection: [keep-alive] + Content-Length: ['0'] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.5.3 (Windows-2012ServerR2-6.3.9600-SP0) requests/2.9.1 + msrest/0.4.4 msrest_azure/0.4.7 storagemanagementclient/0.31.0 Azure-SDK-For-Python + AZURECLI/2.0.1+dev] + accept-language: [en-US] + method: POST + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/clitest000003/listKeys?api-version=2016-12-01 + response: + body: {string: '{"keys":[{"keyName":"key1","permissions":"Full","value":"Ktj5FMj8DV4Ah6qkBqOG9HrGwBogFFZPhONBDjiBEbrsDOIqRwvYT9JGgA6JUkNEDMfZTpA7RYU9Yhf9ck7ULQ=="},{"keyName":"key2","permissions":"Full","value":"2iYVCen0ZWi6p4eldMvhPw9NOOIq0vI7QkA8y/J8EpuUtQCwSAy1AxkSvWevf+8vLUiG2MQTXTKYjWz1/r90Cw=="}]} + + '} + headers: + cache-control: [no-cache] + content-length: ['289'] + content-type: [application/json] + date: ['Fri, 17 Mar 2017 00:34:49 GMT'] + expires: ['-1'] + pragma: [no-cache] + server: [Microsoft-Azure-Storage-Resource-Provider/1.0, Microsoft-HTTPAPI/2.0] + strict-transport-security: [max-age=31536000; includeSubDomains] + transfer-encoding: [chunked] + vary: [Accept-Encoding] + x-ms-ratelimit-remaining-subscription-writes: ['1199'] + status: {code: 200, message: OK} +- request: + body: null + headers: + Connection: [keep-alive] + Content-Length: ['0'] + User-Agent: [Azure-Storage/0.33.0 (Python CPython 3.5.3; Windows 2012ServerR2) + AZURECLI/2.0.1+dev] + x-ms-date: ['Fri, 17 Mar 2017 00:34:50 GMT'] + x-ms-version: ['2015-07-08'] + method: PUT + uri: https://clitest000003.blob.core.windows.net/bacpacs?restype=container + response: + body: {string: ''} + headers: + date: ['Fri, 17 Mar 2017 00:34:49 GMT'] + etag: ['"0x8D46CCD6C1B6097"'] + last-modified: ['Fri, 17 Mar 2017 00:34:50 GMT'] + server: [Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0] + transfer-encoding: [chunked] + x-ms-version: ['2015-07-08'] + status: {code: 201, message: Created} +- request: + body: 'b''{"storageKeyType": "StorageAccessKey", "administratorLoginPassword": + "SecretPassword123", "storageUri": "https://clitest000003.blob.core.windows.net/bacpacs/testbacpac.bacpac", + "administratorLogin": "admin123", "storageKey": "Ktj5FMj8DV4Ah6qkBqOG9HrGwBogFFZPhONBDjiBEbrsDOIqRwvYT9JGgA6JUkNEDMfZTpA7RYU9Yhf9ck7ULQ=="}''' + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [sql db export] + Connection: [keep-alive] + Content-Length: ['327'] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.5.3 (Windows-2012ServerR2-6.3.9600-SP0) requests/2.9.1 + msrest/0.4.4 msrest_azure/0.4.7 sqlmanagementclient/0.3.2 Azure-SDK-For-Python + AZURECLI/2.0.1+dev] + accept-language: [en-US] + method: POST + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb01/export?api-version=2014-04-01 + response: + body: {string: '{"operation":"Export","startTime":"\/Date(1489710891509)\/"}'} + headers: + cache-control: ['no-store, no-cache'] + content-length: ['60'] + content-type: [application/xml; charset=utf-8] + dataserviceversion: [3.0;] + date: ['Fri, 17 Mar 2017 00:34:52 GMT'] + location: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb01/importExportOperationResults/e4023da1-96de-4ed6-bfcd-d84e5576f036?api-version=2014-04-01-Preview'] + preference-applied: [return-content] + retry-after: ['30'] + server: [Microsoft-HTTPAPI/2.0] + strict-transport-security: [max-age=31536000; includeSubDomains] + x-content-type-options: [nosniff] + x-ms-ratelimit-remaining-subscription-writes: ['1199'] + status: {code: 202, message: Accepted} +- request: + body: null + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [sql db export] + Connection: [keep-alive] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.5.3 (Windows-2012ServerR2-6.3.9600-SP0) requests/2.9.1 + msrest/0.4.4 msrest_azure/0.4.7 sqlmanagementclient/0.3.2 Azure-SDK-For-Python + AZURECLI/2.0.1+dev] + accept-language: [en-US] + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb01/importExportOperationResults/e4023da1-96de-4ed6-bfcd-d84e5576f036?api-version=2014-04-01-Preview + response: + body: {string: '{"blobUri":"https:\/\/clitest000003.blob.core.windows.net\/bacpacs\/testbacpac.bacpac","databaseName":"cliautomationdb01","errorMessage":null,"lastModifiedTime":"3\/17\/2017 + 12:34:52 AM","queuedTime":"3\/17\/2017 12:34:52 AM","requestId":"e4023da1-96de-4ed6-bfcd-d84e5576f036","requestType":"Export","serverName":"clitestserver000002.database.windows.net","status":"Running, + Progress = 0%"}'} + headers: + cache-control: ['no-store, no-cache'] + content-length: ['445'] + content-type: [application/json; odata=minimalmetadata; streaming=true; charset=utf-8] + dataserviceversion: [3.0;] + date: ['Fri, 17 Mar 2017 00:35:23 GMT'] + location: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb01/importExportOperationResults/e4023da1-96de-4ed6-bfcd-d84e5576f036?api-version=2014-04-01-Preview'] + retry-after: ['30'] + server: [Microsoft-HTTPAPI/2.0] + strict-transport-security: [max-age=31536000; includeSubDomains] + x-content-type-options: [nosniff] + status: {code: 202, message: Accepted} +- request: + body: null + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [sql db export] + Connection: [keep-alive] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.5.3 (Windows-2012ServerR2-6.3.9600-SP0) requests/2.9.1 + msrest/0.4.4 msrest_azure/0.4.7 sqlmanagementclient/0.3.2 Azure-SDK-For-Python + AZURECLI/2.0.1+dev] + accept-language: [en-US] + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb01/importExportOperationResults/e4023da1-96de-4ed6-bfcd-d84e5576f036?api-version=2014-04-01-Preview + response: + body: {string: '{"blobUri":"https:\/\/clitest000003.blob.core.windows.net\/bacpacs\/testbacpac.bacpac","databaseName":"cliautomationdb01","errorMessage":null,"lastModifiedTime":"3\/17\/2017 + 12:34:52 AM","queuedTime":"3\/17\/2017 12:34:52 AM","requestId":"e4023da1-96de-4ed6-bfcd-d84e5576f036","requestType":"Export","serverName":"clitestserver000002.database.windows.net","status":"Running, + Progress = 0%"}'} + headers: + cache-control: ['no-store, no-cache'] + content-length: ['445'] + content-type: [application/json; odata=minimalmetadata; streaming=true; charset=utf-8] + dataserviceversion: [3.0;] + date: ['Fri, 17 Mar 2017 00:35:53 GMT'] + location: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb01/importExportOperationResults/e4023da1-96de-4ed6-bfcd-d84e5576f036?api-version=2014-04-01-Preview'] + retry-after: ['30'] + server: [Microsoft-HTTPAPI/2.0] + strict-transport-security: [max-age=31536000; includeSubDomains] + x-content-type-options: [nosniff] + status: {code: 202, message: Accepted} +- request: + body: null + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [sql db export] + Connection: [keep-alive] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.5.3 (Windows-2012ServerR2-6.3.9600-SP0) requests/2.9.1 + msrest/0.4.4 msrest_azure/0.4.7 sqlmanagementclient/0.3.2 Azure-SDK-For-Python + AZURECLI/2.0.1+dev] + accept-language: [en-US] + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb01/importExportOperationResults/e4023da1-96de-4ed6-bfcd-d84e5576f036?api-version=2014-04-01-Preview + response: + body: {string: '{"blobUri":"https:\/\/clitest000003.blob.core.windows.net\/bacpacs\/testbacpac.bacpac","databaseName":"cliautomationdb01","errorMessage":null,"lastModifiedTime":"3\/17\/2017 + 12:34:52 AM","queuedTime":"3\/17\/2017 12:34:52 AM","requestId":"e4023da1-96de-4ed6-bfcd-d84e5576f036","requestType":"Export","serverName":"clitestserver000002.database.windows.net","status":"Running, + Progress = 0%"}'} + headers: + cache-control: ['no-store, no-cache'] + content-length: ['445'] + content-type: [application/json; odata=minimalmetadata; streaming=true; charset=utf-8] + dataserviceversion: [3.0;] + date: ['Fri, 17 Mar 2017 00:36:23 GMT'] + location: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb01/importExportOperationResults/e4023da1-96de-4ed6-bfcd-d84e5576f036?api-version=2014-04-01-Preview'] + retry-after: ['30'] + server: [Microsoft-HTTPAPI/2.0] + strict-transport-security: [max-age=31536000; includeSubDomains] + x-content-type-options: [nosniff] + status: {code: 202, message: Accepted} +- request: + body: null + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [sql db export] + Connection: [keep-alive] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.5.3 (Windows-2012ServerR2-6.3.9600-SP0) requests/2.9.1 + msrest/0.4.4 msrest_azure/0.4.7 sqlmanagementclient/0.3.2 Azure-SDK-For-Python + AZURECLI/2.0.1+dev] + accept-language: [en-US] + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb01/importExportOperationResults/e4023da1-96de-4ed6-bfcd-d84e5576f036?api-version=2014-04-01-Preview + response: + body: {string: '{"blobUri":"https:\/\/clitest000003.blob.core.windows.net\/bacpacs\/testbacpac.bacpac","databaseName":"cliautomationdb01","errorMessage":null,"lastModifiedTime":"3\/17\/2017 + 12:34:52 AM","queuedTime":"3\/17\/2017 12:34:52 AM","requestId":"e4023da1-96de-4ed6-bfcd-d84e5576f036","requestType":"Export","serverName":"clitestserver000002.database.windows.net","status":"Running, + Progress = 0%"}'} + headers: + cache-control: ['no-store, no-cache'] + content-length: ['445'] + content-type: [application/json; odata=minimalmetadata; streaming=true; charset=utf-8] + dataserviceversion: [3.0;] + date: ['Fri, 17 Mar 2017 00:36:54 GMT'] + location: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb01/importExportOperationResults/e4023da1-96de-4ed6-bfcd-d84e5576f036?api-version=2014-04-01-Preview'] + retry-after: ['30'] + server: [Microsoft-HTTPAPI/2.0] + strict-transport-security: [max-age=31536000; includeSubDomains] + x-content-type-options: [nosniff] + status: {code: 202, message: Accepted} +- request: + body: null + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [sql db export] + Connection: [keep-alive] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.5.3 (Windows-2012ServerR2-6.3.9600-SP0) requests/2.9.1 + msrest/0.4.4 msrest_azure/0.4.7 sqlmanagementclient/0.3.2 Azure-SDK-For-Python + AZURECLI/2.0.1+dev] + accept-language: [en-US] + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb01/importExportOperationResults/e4023da1-96de-4ed6-bfcd-d84e5576f036?api-version=2014-04-01-Preview + response: + body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb01/importExportOperationResults/e4023da1-96de-4ed6-bfcd-d84e5576f036","name":"e4023da1-96de-4ed6-bfcd-d84e5576f036","type":"Microsoft.Sql/servers/databases/importExportOperationResults","properties":{"requestId":"e4023da1-96de-4ed6-bfcd-d84e5576f036","requestType":"Export","queuedTime":"3/17/2017 + 12:34:52 AM","lastModifiedTime":"3/17/2017 12:37:11 AM","blobUri":"https://clitest000003.blob.core.windows.net/bacpacs/testbacpac.bacpac","serverName":"clitestserver000002","databaseName":"cliautomationdb01","status":"Completed","errorMessage":null}}'} + headers: + cache-control: ['no-store, no-cache'] + content-length: ['873'] + content-type: [application/json; odata=minimalmetadata; streaming=true; charset=utf-8] + dataserviceversion: [3.0;] + date: ['Fri, 17 Mar 2017 00:37:25 GMT'] + server: [Microsoft-HTTPAPI/2.0] + strict-transport-security: [max-age=31536000; includeSubDomains] + transfer-encoding: [chunked] + vary: [Accept-Encoding] + x-content-type-options: [nosniff] + status: {code: 200, message: OK} +- request: + body: 'b''{"properties": {"storageKey": "Ktj5FMj8DV4Ah6qkBqOG9HrGwBogFFZPhONBDjiBEbrsDOIqRwvYT9JGgA6JUkNEDMfZTpA7RYU9Yhf9ck7ULQ==", + "storageKeyType": "StorageAccessKey", "administratorLoginPassword": "SecretPassword123", + "storageUri": "https://clitest000003.blob.core.windows.net/bacpacs/testbacpac.bacpac", + "administratorLogin": "admin123", "operationMode": "Import"}}''' + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [sql db import] + Connection: [keep-alive] + Content-Length: ['370'] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.5.3 (Windows-2012ServerR2-6.3.9600-SP0) requests/2.9.1 + msrest/0.4.4 msrest_azure/0.4.7 sqlmanagementclient/0.3.2 Azure-SDK-For-Python + AZURECLI/2.0.1+dev] + accept-language: [en-US] + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb02/extensions/import?api-version=2014-04-01 + response: + body: {string: '{"operation":"Import","startTime":"\/Date(1489711048701)\/"}'} + headers: + cache-control: ['no-store, no-cache'] + content-length: ['60'] + content-type: [application/json; odata=minimalmetadata; streaming=true; charset=utf-8] + dataserviceversion: [3.0;] + date: ['Fri, 17 Mar 2017 00:37:29 GMT'] + location: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb02/extensions/import/importExtensionOperationResults/e400a329-0fe1-44f1-885f-d708e03058a3?api-version=2014-04-01-Preview'] + preference-applied: [return-content] + retry-after: ['30'] + server: [Microsoft-HTTPAPI/2.0] + strict-transport-security: [max-age=31536000; includeSubDomains] + x-content-type-options: [nosniff] + x-ms-ratelimit-remaining-subscription-writes: ['1199'] + status: {code: 202, message: Accepted} +- request: + body: null + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [sql db import] + Connection: [keep-alive] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.5.3 (Windows-2012ServerR2-6.3.9600-SP0) requests/2.9.1 + msrest/0.4.4 msrest_azure/0.4.7 sqlmanagementclient/0.3.2 Azure-SDK-For-Python + AZURECLI/2.0.1+dev] + accept-language: [en-US] + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb02/extensions/import/importExtensionOperationResults/e400a329-0fe1-44f1-885f-d708e03058a3?api-version=2014-04-01-Preview + response: + body: {string: '{"blobUri":"https:\/\/clitest000003.blob.core.windows.net\/bacpacs\/testbacpac.bacpac","databaseName":"cliautomationdb02","errorMessage":null,"lastModifiedTime":"3\/17\/2017 + 12:37:29 AM","queuedTime":"3\/17\/2017 12:37:29 AM","requestId":"e400a329-0fe1-44f1-885f-d708e03058a3","requestType":"Import","serverName":"clitestserver000002.database.windows.net","status":"Running, + Progress = 5.00 %"}'} + headers: + cache-control: ['no-store, no-cache'] + content-length: ['449'] + content-type: [application/json; odata=minimalmetadata; streaming=true; charset=utf-8] + dataserviceversion: [3.0;] + date: ['Fri, 17 Mar 2017 00:37:59 GMT'] + location: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb02/extensions/import/importExtensionOperationResults/e400a329-0fe1-44f1-885f-d708e03058a3?api-version=2014-04-01-Preview'] + retry-after: ['30'] + server: [Microsoft-HTTPAPI/2.0] + strict-transport-security: [max-age=31536000; includeSubDomains] + x-content-type-options: [nosniff] + status: {code: 202, message: Accepted} +- request: + body: null + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [sql db import] + Connection: [keep-alive] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.5.3 (Windows-2012ServerR2-6.3.9600-SP0) requests/2.9.1 + msrest/0.4.4 msrest_azure/0.4.7 sqlmanagementclient/0.3.2 Azure-SDK-For-Python + AZURECLI/2.0.1+dev] + accept-language: [en-US] + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb02/extensions/import/importExtensionOperationResults/e400a329-0fe1-44f1-885f-d708e03058a3?api-version=2014-04-01-Preview + response: + body: {string: '{"blobUri":"https:\/\/clitest000003.blob.core.windows.net\/bacpacs\/testbacpac.bacpac","databaseName":"cliautomationdb02","errorMessage":null,"lastModifiedTime":"3\/17\/2017 + 12:37:29 AM","queuedTime":"3\/17\/2017 12:37:29 AM","requestId":"e400a329-0fe1-44f1-885f-d708e03058a3","requestType":"Import","serverName":"clitestserver000002.database.windows.net","status":"Running, + Progress = 5.00 %"}'} + headers: + cache-control: ['no-store, no-cache'] + content-length: ['449'] + content-type: [application/json; odata=minimalmetadata; streaming=true; charset=utf-8] + dataserviceversion: [3.0;] + date: ['Fri, 17 Mar 2017 00:38:30 GMT'] + location: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb02/extensions/import/importExtensionOperationResults/e400a329-0fe1-44f1-885f-d708e03058a3?api-version=2014-04-01-Preview'] + retry-after: ['30'] + server: [Microsoft-HTTPAPI/2.0] + strict-transport-security: [max-age=31536000; includeSubDomains] + x-content-type-options: [nosniff] + status: {code: 202, message: Accepted} +- request: + body: null + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [sql db import] + Connection: [keep-alive] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.5.3 (Windows-2012ServerR2-6.3.9600-SP0) requests/2.9.1 + msrest/0.4.4 msrest_azure/0.4.7 sqlmanagementclient/0.3.2 Azure-SDK-For-Python + AZURECLI/2.0.1+dev] + accept-language: [en-US] + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb02/extensions/import/importExtensionOperationResults/e400a329-0fe1-44f1-885f-d708e03058a3?api-version=2014-04-01-Preview + response: + body: {string: '{"blobUri":"https:\/\/clitest000003.blob.core.windows.net\/bacpacs\/testbacpac.bacpac","databaseName":"cliautomationdb02","errorMessage":null,"lastModifiedTime":"3\/17\/2017 + 12:37:29 AM","queuedTime":"3\/17\/2017 12:37:29 AM","requestId":"e400a329-0fe1-44f1-885f-d708e03058a3","requestType":"Import","serverName":"clitestserver000002.database.windows.net","status":"Running, + Progress = 5.00 %"}'} + headers: + cache-control: ['no-store, no-cache'] + content-length: ['449'] + content-type: [application/json; odata=minimalmetadata; streaming=true; charset=utf-8] + dataserviceversion: [3.0;] + date: ['Fri, 17 Mar 2017 00:39:01 GMT'] + location: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb02/extensions/import/importExtensionOperationResults/e400a329-0fe1-44f1-885f-d708e03058a3?api-version=2014-04-01-Preview'] + retry-after: ['30'] + server: [Microsoft-HTTPAPI/2.0] + strict-transport-security: [max-age=31536000; includeSubDomains] + x-content-type-options: [nosniff] + status: {code: 202, message: Accepted} +- request: + body: null + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [sql db import] + Connection: [keep-alive] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.5.3 (Windows-2012ServerR2-6.3.9600-SP0) requests/2.9.1 + msrest/0.4.4 msrest_azure/0.4.7 sqlmanagementclient/0.3.2 Azure-SDK-For-Python + AZURECLI/2.0.1+dev] + accept-language: [en-US] + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb02/extensions/import/importExtensionOperationResults/e400a329-0fe1-44f1-885f-d708e03058a3?api-version=2014-04-01-Preview + response: + body: {string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Sql/servers/clitestserver000002/databases/cliautomationdb02/extensions/import","name":"import","type":"Microsoft.Sql/servers/databases/extensions","properties":{"requestId":"e400a329-0fe1-44f1-885f-d708e03058a3","requestType":"Import","queuedTime":"3/17/2017 + 12:37:29 AM","lastModifiedTime":"3/17/2017 12:39:23 AM","blobUri":"https://clitest000003.blob.core.windows.net/bacpacs/testbacpac.bacpac","serverName":"clitestserver000002","databaseName":"cliautomationdb02","status":"Completed","errorMessage":null}}'} + headers: + cache-control: ['no-store, no-cache'] + content-length: ['777'] + content-type: [application/json; odata=minimalmetadata; streaming=true; charset=utf-8] + dataserviceversion: [3.0;] + date: ['Fri, 17 Mar 2017 00:39:32 GMT'] + server: [Microsoft-HTTPAPI/2.0] + strict-transport-security: [max-age=31536000; includeSubDomains] + x-content-type-options: [nosniff] + status: {code: 201, message: Created} +- request: + body: null + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + CommandName: [group delete] + Connection: [keep-alive] + Content-Length: ['0'] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.5.3 (Windows-2012ServerR2-6.3.9600-SP0) requests/2.9.1 + msrest/0.4.4 msrest_azure/0.4.7 resourcemanagementclient/0.30.2 Azure-SDK-For-Python + AZURECLI/2.0.1+dev] + accept-language: [en-US] + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/clitest.rg000001?api-version=2016-09-01 + response: + body: {string: ''} + headers: + cache-control: [no-cache] + content-length: ['0'] + date: ['Fri, 17 Mar 2017 00:39:34 GMT'] + expires: ['-1'] + location: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1DTElURVNUOjJFUkc2MzFEODI4NDEyOTRDREIyRDE5QjUxREVFOTM5MTk4QTcwRXxFOUE2NzU1RkRCMjA5Q0ExLVdFU1RVUyIsImpvYkxvY2F0aW9uIjoid2VzdHVzIn0?api-version=2016-09-01'] + pragma: [no-cache] + retry-after: ['15'] + strict-transport-security: [max-age=31536000; includeSubDomains] + x-ms-ratelimit-remaining-subscription-writes: ['1199'] + status: {code: 202, message: Accepted} +version: 1 diff --git a/src/command_modules/azure-cli-sql/tests/test_sql_commands.py b/src/command_modules/azure-cli-sql/tests/test_sql_commands.py index f453f5f629e..63e2472ffbf 100644 --- a/src/command_modules/azure-cli-sql/tests/test_sql_commands.py +++ b/src/command_modules/azure-cli-sql/tests/test_sql_commands.py @@ -9,6 +9,7 @@ JMESPathCheck, NoneCheck, ResourceGroupPreparer, + StorageAccountPreparer, ScenarioTest) from azure.cli.testsdk.preparers import ( AbstractPreparer, @@ -865,3 +866,84 @@ def test_sql_elastic_pools_mgmt(self, resource_group, resource_group_location, s self.cmd('sql elastic-pool delete -g {} --server {} --name {}' .format(rg, server, self.pool_name), checks=[NoneCheck()]) + + +class SqlServerImportExportMgmtScenarioTest(ScenarioTest): + @ResourceGroupPreparer() + @SqlServerPreparer() + @StorageAccountPreparer() + def test_sql_db_import_export_mgmt(self, resource_group, resource_group_location, server, storage_account): + location_long_name = 'West US' + admin_login = 'admin123' + admin_password = 'SecretPassword123' + db_name = 'cliautomationdb01' + db_name2 = 'cliautomationdb02' + container = 'bacpacs' + + firewall_rule_1 = 'allowAllIps' + start_ip_address_1 = '0.0.0.0' + end_ip_address_1 = '255.255.255.255' + + loc_long = location_long_name + rg = resource_group + sa = storage_account + + # create server firewall rule + self.cmd('sql server firewall-rule create --name {} -g {} --server {} ' + '--start-ip-address {} --end-ip-address {}' + .format(firewall_rule_1, rg, server, + start_ip_address_1, end_ip_address_1), + checks=[ + JMESPathCheck('name', firewall_rule_1), + JMESPathCheck('resourceGroup', rg), + JMESPathCheck('startIpAddress', start_ip_address_1), + JMESPathCheck('endIpAddress', end_ip_address_1)]) + + # create db + self.cmd('sql db create -g {} --server {} --name {}' + .format(rg, server, db_name), + checks=[ + JMESPathCheck('resourceGroup', rg), + JMESPathCheck('name', db_name), + JMESPathCheck('location', loc_long), + JMESPathCheck('elasticPoolName', None), + JMESPathCheck('status', 'Online')]) + + self.cmd('sql db create -g {} --server {} --name {}' + .format(rg, server, db_name2), + checks=[ + JMESPathCheck('resourceGroup', rg), + JMESPathCheck('name', db_name2), + JMESPathCheck('location', loc_long), + JMESPathCheck('elasticPoolName', None), + JMESPathCheck('status', 'Online')]) + + # Backup to new dacpac + # get storage account endpoint + storage_endpoint = self.cmd('storage account show -g {} -n {}' + ' --query primaryEndpoints.blob' + .format(rg, storage_account)).get_output_in_json() + + # get storage account key + key = self.cmd('storage account keys list -g {} -n {} --query [0].value' + .format(rg, storage_account)).get_output_in_json() + + # create storage account blob container + self.cmd('storage container create -n {} --account-name {} --account-key {} ' + .format(container, sa, key), + checks=[ + JMESPathCheck('created', True)]) + + # export database to blob container + self.cmd('sql db export -s {} -n {} -g {} -p {} -u {}' + ' --storage-key {} --storage-key-type StorageAccessKey' + ' --storage-uri {}{}/testbacpac.bacpac' + .format(server, db_name, rg, admin_password, admin_login, key, + storage_endpoint, container)) + + # import bacpac to second database + self.cmd('sql db import -s {} -n {} -g {} -p {} -u {}' + ' --storage-key {} --storage-key-type StorageAccessKey' + ' --storage-uri {}{}/testbacpac.bacpac' + .format(server, db_name2, rg, admin_password, admin_login, key, + storage_endpoint, container))