Skip to content

Commit 2816742

Browse files
committed
Remove StorageContainer Parameter from Import/Export Commands
Remove StorageContainer Parameter from Import/Export Commands
1 parent d877f3b commit 2816742

File tree

5 files changed

+73
-114
lines changed

5 files changed

+73
-114
lines changed

src/ServiceManagement/Sql/Commands.SqlDatabase.Test/TestScripts/Database/ExportTests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function TestExportWithRequestObject
2424
$BlobName = $DatabaseName1 + ".bacpac"
2525
Write-Output "Exporting to Blob: $BlobName"
2626

27-
$Request = Start-AzureSqlDatabaseExport -SqlConnectionContext $context -StorageContainerName $container.Name -StorageContext $StgCtx `
27+
$Request = Start-AzureSqlDatabaseExport -SqlConnectionContext $context -StorageContainer $container `
2828
-DatabaseName $DatabaseName1 -BlobName $BlobName
2929
Assert {$Request} "Failed to initiate the first export operation"
3030
$id = ($Request.RequestGuid)

src/ServiceManagement/Sql/Commands.SqlDatabase.Test/TestScripts/Database/ImportTests.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function TestImportWithRequestObject
2525
$dbName = $DatabaseName1 + "-import1"
2626
Write-Output "Importing from Blob: $BlobName"
2727

28-
$Request = Start-AzureSqlDatabaseImport -SqlConnectionContext $context -StorageContainerName $container.Name -StorageContext $StgCtx `
28+
$Request = Start-AzureSqlDatabaseImport -SqlConnectionContext $context -StorageContainer $container `
2929
-DatabaseName $dbName -BlobName $BlobName
3030
Assert {$Request} "Failed to initiate the first import opertaion"
3131
$id = ($Request.RequestGuid)
@@ -79,21 +79,21 @@ function TestImportWithRequestObjectAndOptionalParameters
7979
$dbName = $DatabaseName1 + "Options-edition"
8080
Write-Output "Database name: $dbName"
8181
TestImportCommandHelper `
82-
{ Start-AzureSqlDatabaseImport -SqlConnectionContext $context -StorageContainerName $container.Name -StorageContext $StgCtx `
82+
{ Start-AzureSqlDatabaseImport -SqlConnectionContext $context -StorageContainer $container `
8383
-DatabaseName $dbName -BlobName $BlobName -Edition "Business" }
8484

8585
Write-Output "Running test for import with optional size parameter"
8686
$dbName = $DatabaseName1 + "Options-size"
8787
Write-Output "Database name: $dbName"
8888
TestImportCommandHelper `
89-
{ Start-AzureSqlDatabaseImport -SqlConnectionContext $context -StorageContainerName $container.Name -StorageContext $StgCtx `
89+
{ Start-AzureSqlDatabaseImport -SqlConnectionContext $context -StorageContainer $container `
9090
-DatabaseName $dbName -BlobName $BlobName -DatabaseMaxSize 5 }
9191

9292
Write-Output "Running test for import with optional edition and size parameter"
9393
$dbName = $DatabaseName1 + "Options-edition"
9494
Write-Output "Database name: $dbName"
9595
TestImportCommandHelper `
96-
{ Start-AzureSqlDatabaseImport -SqlConnectionContext $context -StorageContainerName $container.Name -StorageContext $StgCtx `
96+
{ Start-AzureSqlDatabaseImport -SqlConnectionContext $context -StorageContainer $container `
9797
-DatabaseName $dbName -BlobName $BlobName -Edition "Business" -DatabaseMaxSize 20 }
9898
}
9999

src/ServiceManagement/Sql/Commands.SqlDatabase/Database/Cmdlet/StartAzureSqlDatabaseExport.cs

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ namespace Microsoft.WindowsAzure.Commands.SqlDatabase.Database.Cmdlet
3131
public class StartAzureSqlDatabaseExport : SqlDatabaseCmdletBase
3232
{
3333
#region Parameter Set names
34-
34+
35+
/// <summary>
36+
/// The name of the parameter set that uses the Azure Storage Container object
37+
/// </summary>
38+
internal const string ByContainerObjectParameterSet =
39+
"ByContainerObject";
40+
3541
/// <summary>
3642
/// The name of the parameter set that uses the storage container name
3743
/// </summary>
@@ -51,6 +57,15 @@ public class StartAzureSqlDatabaseExport : SqlDatabaseCmdletBase
5157
[ValidateNotNullOrEmpty]
5258
public ISqlServerConnectionInformation SqlConnectionContext { get; set; }
5359

60+
/// <summary>
61+
/// Gets or sets the destination storage container for the blob
62+
/// </summary>
63+
[Parameter(Mandatory = true, Position = 1,
64+
ParameterSetName = ByContainerObjectParameterSet,
65+
HelpMessage = "The Azure Storage Container to place the blob in.")]
66+
[ValidateNotNull]
67+
public AzureStorageContainer StorageContainer { get; set; }
68+
5469
/// <summary>
5570
/// Gets or sets the storage context
5671
/// </summary>
@@ -72,6 +87,9 @@ public class StartAzureSqlDatabaseExport : SqlDatabaseCmdletBase
7287
/// <summary>
7388
/// Gets or sets the name of the database to export
7489
/// </summary>
90+
[Parameter(Mandatory = true, Position = 2,
91+
ParameterSetName = ByContainerObjectParameterSet,
92+
HelpMessage = "The name of the database to export")]
7593
[Parameter(Mandatory = true, Position = 3,
7694
ParameterSetName = ByContainerNameParameterSet,
7795
HelpMessage = "The name of the database to export")]
@@ -81,6 +99,9 @@ public class StartAzureSqlDatabaseExport : SqlDatabaseCmdletBase
8199
/// <summary>
82100
/// Gets or sets name of the blob to use for the export
83101
/// </summary>
102+
[Parameter(Mandatory = true, Position = 3,
103+
ParameterSetName = ByContainerObjectParameterSet,
104+
HelpMessage = "The name of the blob to use for the export")]
84105
[Parameter(Mandatory = true, Position = 4,
85106
ParameterSetName = ByContainerNameParameterSet,
86107
HelpMessage = "The name of the blob to use for the export")]
@@ -172,6 +193,16 @@ public override void ExecuteCmdlet()
172193
this.BlobName;
173194
break;
174195

196+
case ByContainerObjectParameterSet:
197+
accessKey = Convert.ToBase64String(
198+
this.StorageContainer.CloudBlobContainer.ServiceClient.Credentials.ExportKey());
199+
200+
blobUri =
201+
this.StorageContainer.Context.BlobEndPoint +
202+
this.StorageContainer.Name + "/" +
203+
this.BlobName;
204+
break;
205+
175206
default:
176207
throw new NotSupportedException("ParameterSet");
177208
}

src/ServiceManagement/Sql/Commands.SqlDatabase/Database/Cmdlet/StartAzureSqlDatabaseImport.cs

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,13 @@ namespace Microsoft.WindowsAzure.Commands.SqlDatabase.Database.Cmdlet
3333
public class StartAzureSqlDatabaseImport : SqlDatabaseCmdletBase
3434
{
3535
#region Parameter Set names
36-
36+
37+
/// <summary>
38+
/// The name of the parameter set that uses the Azure Storage Container object
39+
/// </summary>
40+
internal const string ByContainerObjectParameterSet =
41+
"ByContainerObject";
42+
3743
/// <summary>
3844
/// The name of the parameter set that uses the storage container name
3945
/// </summary>
@@ -53,6 +59,15 @@ public class StartAzureSqlDatabaseImport : SqlDatabaseCmdletBase
5359
[ValidateNotNullOrEmpty]
5460
public ISqlServerConnectionInformation SqlConnectionContext { get; set; }
5561

62+
/// <summary>
63+
/// Gets or sets the storage container object containing the blob
64+
/// </summary>
65+
[Parameter(Mandatory = true, Position = 1,
66+
ParameterSetName = ByContainerObjectParameterSet,
67+
HelpMessage = "The Azure Storage Container to place the blob in.")]
68+
[ValidateNotNull]
69+
public AzureStorageContainer StorageContainer { get; set; }
70+
5671
/// <summary>
5772
/// Gets or sets the storage context
5873
/// </summary>
@@ -74,6 +89,9 @@ public class StartAzureSqlDatabaseImport : SqlDatabaseCmdletBase
7489
/// <summary>
7590
/// Gets or sets the name for the imported database
7691
/// </summary>
92+
[Parameter(Mandatory = true, Position = 2,
93+
ParameterSetName = ByContainerObjectParameterSet,
94+
HelpMessage = "The name for the imported database")]
7795
[Parameter(Mandatory = true, Position = 3,
7896
ParameterSetName = ByContainerNameParameterSet,
7997
HelpMessage = "The name for the imported database")]
@@ -83,6 +101,9 @@ public class StartAzureSqlDatabaseImport : SqlDatabaseCmdletBase
83101
/// <summary>
84102
/// Gets or sets name of the blob to use for the import
85103
/// </summary>
104+
[Parameter(Mandatory = true, Position = 3,
105+
ParameterSetName = ByContainerObjectParameterSet,
106+
HelpMessage = "The name of the blob to use for the import")]
86107
[Parameter(Mandatory = true, Position = 4,
87108
ParameterSetName = ByContainerNameParameterSet,
88109
HelpMessage = "The name of the blob to use for the import")]
@@ -196,6 +217,17 @@ public override void ExecuteCmdlet()
196217
this.BlobName;
197218
break;
198219

220+
case ByContainerObjectParameterSet:
221+
accessKey =
222+
System.Convert.ToBase64String(
223+
this.StorageContainer.CloudBlobContainer.ServiceClient.Credentials.ExportKey());
224+
225+
blobUri =
226+
this.StorageContainer.Context.BlobEndPoint +
227+
this.StorageContainer.Name + "/" +
228+
this.BlobName;
229+
break;
230+
199231
default:
200232
throw new NotSupportedException("ParameterSet");
201233
}

0 commit comments

Comments
 (0)