Skip to content

Commit 91bcc78

Browse files
committed
Merge pull request #206 from huangpf/dev
HPF PR: dev <- huangpf:dev
2 parents 0fac109 + 887e17d commit 91bcc78

File tree

47 files changed

+1771
-982
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1771
-982
lines changed

ChangeLog.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
##2016.05.03 version 1.4.0
2+
* Azure Storage
3+
* Upgrade to Microsoft.Azure.Management.Storage nuget package v5.0 preview
4+
* Add Encryption and Hot/Cool features support to resource mode storage account cmdlets
5+
- New-AzureRmStorageAccount
6+
- Set-AzureRmStorageAccount
7+
* Add "Add" and "Create" permission to Blob SAS cmdlets
8+
- New-AzureStorageBlobSASToken
9+
- New-AzureStorageContainerSASToken
10+
- New-AzureStorageContainerStoredAccessPolicy
11+
- Set-AzureStorageContainerStoredAccessPolicy
12+
* Add "Create" permission to File SAS cmdlets
13+
- New-AzureStorageFileSASToken
14+
- New-AzureStorageShareSASToken
15+
- New-AzureStorageShareStoredAccessPolicy
16+
- Set-AzureStorageShareStoredAccessPolicy
17+
118
##2016.04.19 version 1.3.2
219
* Add support for specifying NIC/VMSS as application gateway backend address
320
* Fix HDI ADL cluster creation and live test

setup/azurecmdfiles.wxi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2538,6 +2538,9 @@
25382538
<Component Id="cmpA2A4B67ACC8738C88A82A9576BD82026" Guid="*">
25392539
<File Id="fil2E6EA8F5997FA6DBE29FCE3A58F051DF" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.Storage\Microsoft.Rest.ClientRuntime.Azure.Authentication.dll" />
25402540
</Component>
2541+
<Component Id="cmp3AE4D7EAA86E455A89006A85332F6B3A" Guid="*">
2542+
<File Id="fil6C5492894C2F4DDD80E710891D53B6D2" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.Storage\Microsoft.Rest.ClientRuntime.Azure.dll" />
2543+
</Component>
25412544
<Component Id="cmpE56C0006C325EFBAD7984DBBCF689FD2" Guid="*">
25422545
<File Id="filDAF92272D69F4A127139311912333F8B" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.Storage\Microsoft.Rest.ClientRuntime.dll" />
25432546
</Component>
@@ -5798,6 +5801,7 @@
57985801
<ComponentRef Id="cmp4EA5A818E3BE7C67C27B69ADABCE5CBF" />
57995802
<ComponentRef Id="cmpBF600E80A7D04977AF21CAA07A79254C" />
58005803
<ComponentRef Id="cmpA2A4B67ACC8738C88A82A9576BD82026" />
5804+
<ComponentRef Id="cmp3AE4D7EAA86E455A89006A85332F6B3A" />
58015805
<ComponentRef Id="cmpE56C0006C325EFBAD7984DBBCF689FD2" />
58025806
<ComponentRef Id="cmpA94FD747C692B4A9A45D9DE5D869DE53" />
58035807
<ComponentRef Id="cmp7F0D9683DB4D431F6A1A42EBCAD0E4E3" />

src/ResourceManager/ApiManagement/Commands.ApiManagement.Test/Commands.ApiManagement.Test.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,9 @@
179179
</ProjectReference>
180180
</ItemGroup>
181181
<ItemGroup>
182+
<None Include="..\..\Common\Commands.ScenarioTests.ResourceManager.Common\AzureRM.Storage.ps1">
183+
<Link>ScenarioTests\AzureRM.Storage.ps1</Link>
184+
</None>
182185
<None Include="packages.config">
183186
<SubType>Designer</SubType>
184187
</None>

src/ResourceManager/ApiManagement/Commands.ApiManagement.Test/ScenarioTests/ApiManagementTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ private void RunPowerShellTest(params string[] scripts)
176176
_helper.RMProfileModule,
177177
_helper.RMResourceModule,
178178
_helper.RMStorageDataPlaneModule,
179-
_helper.RMStorageModule,
180-
_helper.GetRMModulePath("AzureRM.ApiManagement.psd1"));
179+
_helper.GetRMModulePath("AzureRM.ApiManagement.psd1"),
180+
"AzureRM.Storage.ps1");
181181

182182
_helper.RunPowerShellTest(scripts);
183183
}
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
2+
function Get-AzureRmStorageAccount
3+
{
4+
5+
[CmdletBinding()]
6+
param(
7+
[string] [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)] $ResourceGroupName,
8+
[string] [Parameter(Position=1, ValueFromPipelineByPropertyName=$true)] [alias("StorageAccountName")] $Name)
9+
BEGIN {
10+
$context = Get-Context
11+
$client = Get-StorageClient $context
12+
}
13+
PROCESS {
14+
$getTask = $client.StorageAccounts.GetPropertiesAsync($ResourceGroupName, $name, [System.Threading.CancellationToken]::None)
15+
$sa = $getTask.Result
16+
$account = Get-StorageAccount $ResourceGroupName $Name
17+
Write-Output $account
18+
}
19+
END {}
20+
21+
}
22+
23+
function New-AzureRmStorageAccount
24+
{
25+
[CmdletBinding()]
26+
param(
27+
[string] [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)] $ResourceGroupName,
28+
[string] [Parameter(Position=1, ValueFromPipelineByPropertyName=$true)][alias("StorageAccountName")] $Name,
29+
[string] [Parameter(Position=2, ValueFromPipelineByPropertyName=$true)] $Location,
30+
[string] [Parameter(Position=3, ValueFromPipelineByPropertyName=$true)] $Type)
31+
BEGIN {
32+
$context = Get-Context
33+
$client = Get-StorageClient $context
34+
}
35+
PROCESS {
36+
$createParms = New-Object -Type Microsoft.Azure.Management.Storage.Models.StorageAccountCreateParameters
37+
$createParms.AccountType = [Microsoft.Azure.Management.Storage.Models.AccountType]::StandardLRS
38+
$createParms.Location = $Location
39+
$getTask = $client.StorageAccounts.CreateAsync($ResourceGroupName, $name, $createParms, [System.Threading.CancellationToken]::None)
40+
$sa = $getTask.Result
41+
}
42+
END {}
43+
44+
}
45+
46+
function Get-AzureRmStorageAccountKey
47+
{
48+
[CmdletBinding()]
49+
param(
50+
[string] [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)] $ResourceGroupName,
51+
[string] [Parameter(Position=1, ValueFromPipelineByPropertyName=$true)] [alias("StorageAccountName")] $Name)
52+
BEGIN {
53+
$context = Get-Context
54+
$client = Get-StorageClient $context
55+
}
56+
PROCESS {
57+
$getTask = $client.StorageAccounts.ListKeysAsync($ResourceGroupName, $name, [System.Threading.CancellationToken]::None)
58+
Write-Output $getTask.Result.StorageAccountKeys
59+
}
60+
END {}
61+
}
62+
63+
function Remove-AzureRmStorageAccount
64+
{
65+
66+
[CmdletBinding()]
67+
param(
68+
[string] [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)] $ResourceGroupName,
69+
[string] [Parameter(Position=1, ValueFromPipelineByPropertyName=$true)] [alias("StorageAccountName")] $Name)
70+
BEGIN {
71+
$context = Get-Context
72+
$client = Get-StorageClient $context
73+
}
74+
PROCESS {
75+
$getTask = $client.StorageAccounts.DeleteAsync($ResourceGroupName, $name, [System.Threading.CancellationToken]::None)
76+
$sa = $getTask.Result
77+
}
78+
END {}
79+
80+
}
81+
82+
function Get-Context
83+
{
84+
[Microsoft.Azure.Commands.Common.Authentication.Models.AzureContext]$context = $null
85+
$profile = [Microsoft.WindowsAzure.Commands.Common.AzureRmProfileProvider]::Instance.Profile
86+
if ($profile -ne $null)
87+
{
88+
$context = $profile.Context
89+
}
90+
91+
return $context
92+
}
93+
94+
function Get-StorageClient
95+
{
96+
param([Microsoft.Azure.Commands.Common.Authentication.Models.AzureContext] $context)
97+
$factory = [Microsoft.Azure.Commands.Common.Authentication.AzureSession]::ClientFactory
98+
[System.Type[]]$types = [Microsoft.Azure.Commands.Common.Authentication.Models.AzureContext], [Microsoft.Azure.Commands.Common.Authentication.Models.AzureEnvironment+Endpoint]
99+
$method = [Microsoft.Azure.Commands.Common.Authentication.IClientFactory].GetMethod("CreateClient", $types)
100+
$closedMethod = $method.MakeGenericMethod([Microsoft.Azure.Management.Storage.StorageManagementClient])
101+
$arguments = $context, [Microsoft.Azure.Commands.Common.Authentication.Models.AzureEnvironment+Endpoint]::ResourceManager
102+
$client = $closedMethod.Invoke($factory, $arguments)
103+
return $client
104+
}
105+
106+
function Get-StorageAccount {
107+
param([string] $resourceGroupName, [string] $name)
108+
$endpoints = New-Object PSObject -Property @{"Blob" = "https://$name.blob.core.windows.net/"}
109+
$sa = New-Object PSObject -Property @{"Name" = $name; "ResourceGroupName" = $resourceGroupName;
110+
"PrimaryEndpoints" = $endpoints
111+
}
112+
return $sa
113+
}

src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/Commands.ScenarioTests.ResourceManager.Common.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@
161161
<None Include="Assert.ps1">
162162
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
163163
</None>
164+
<None Include="AzureRM.Storage.ps1">
165+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
166+
</None>
164167
<None Include="Common.ps1">
165168
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
166169
</None>

src/ResourceManager/Compute/Commands.Compute.Test/Commands.Compute.Test.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@
218218
<Link>ScenarioTests\Assert.ps1</Link>
219219
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
220220
</None>
221+
<None Include="..\..\Common\Commands.ScenarioTests.ResourceManager.Common\AzureRM.Storage.ps1">
222+
<Link>ScenarioTests\AzureRM.Storage.ps1</Link>
223+
</None>
221224
<None Include="..\..\Resources\Commands.Resources.Test\ScenarioTests\Common.ps1">
222225
<Link>ScenarioTests\Common.ps1</Link>
223226
<CopyToOutputDirectory>Always</CopyToOutputDirectory>

src/ResourceManager/Compute/Commands.Compute.Test/Common/ComputeTestController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ public void RunPsTestWorkflow(
134134
helper.RMStorageDataPlaneModule,
135135
helper.RMStorageModule,
136136
helper.GetRMModulePath("AzureRM.Compute.psd1"),
137-
helper.GetRMModulePath("AzureRM.Network.psd1"));
137+
helper.GetRMModulePath("AzureRM.Network.psd1"),
138+
"AzureRM.Storage.ps1");
138139

139140
try
140141
{

src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/Common.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,5 +295,9 @@ function Get-SqlDatabaseImportExportTestEnvironmentParameters ($testSuffix)
295295
importBacpacUri = $importBacpacUri;
296296
location = "Australia East";
297297
version = "12.0";
298+
databaseEdition = "Standard";
299+
serviceObjectiveName = "S0";
300+
databaseMaxSizeBytes = "5000000";
301+
authType = "Sql";
298302
}
299303
}

src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/ImportExportTests.ps1

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,36 @@ function Test-ImportDatabase
7676

7777
if($operationName -eq $export){
7878
# Export database.
79-
$exportResponse = New-AzureRmSqlDatabaseExport -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName -StorageKeyType $params.storageKeyType -StorageKey $params.storageKey -StorageUri $params.exportBacpacUri -AdministratorLogin $params.userName -AdministratorLoginPassword $secureString -AuthenticationType Sql
79+
$exportResponse = New-AzureRmSqlDatabaseExport -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName -StorageKeyType $params.storageKeyType -StorageKey $params.storageKey -StorageUri $params.exportBacpacUri -AdministratorLogin $params.userName -AdministratorLoginPassword $secureString -AuthenticationType $params.authType
8080
Assert-NotNull $exportResponse
81-
$operationStatusLink = $exportResponse.OperationStatusLink
81+
$operationStatusLink = $exportResponse.OperationStatusLink
82+
Assert-AreEqual $exportResponse.ResourceGroupName $params.rgname
83+
Assert-AreEqual $exportResponse.ServerName $params.serverName
84+
Assert-AreEqual $exportResponse.DatabaseName $params.databaseName
85+
Assert-AreEqual $exportResponse.StorageKeyType $params.storageKeyType
86+
Assert-Null $exportResponse.StorageKey
87+
Assert-AreEqual $exportResponse.StorageUri $params.exportBacpacUri
88+
Assert-AreEqual $exportResponse.AdministratorLogin $params.userName
89+
Assert-Null $exportResponse.AdministratorLoginPassword
90+
Assert-AreEqual $exportResponse.AuthenticationType $params.authType
8291
}
8392

8493
if($operationName -eq $import){
85-
$importResponse = New-AzureRmSqlDatabaseImport -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName -StorageKeyType $params.storageKeyType -StorageKey $params.storageKey -StorageUri $params.importBacpacUri -AdministratorLogin $params.userName -AdministratorLoginPassword $secureString -Edition Standard -ServiceObjectiveName S0 -DatabaseMaxSizeBytes 5000000 -AuthenticationType Sql
94+
$importResponse = New-AzureRmSqlDatabaseImport -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName -StorageKeyType $params.storageKeyType -StorageKey $params.storageKey -StorageUri $params.importBacpacUri -AdministratorLogin $params.userName -AdministratorLoginPassword $secureString -Edition $params.databaseEdition -ServiceObjectiveName $params.serviceObjectiveName -DatabaseMaxSizeBytes $params.databaseMaxSizeBytes -AuthenticationType $params.authType
8695
Assert-NotNull $importResponse
8796
$operationStatusLink = $importResponse.OperationStatusLink
97+
Assert-AreEqual $importResponse.ResourceGroupName $params.rgname
98+
Assert-AreEqual $importResponse.ServerName $params.serverName
99+
Assert-AreEqual $importResponse.DatabaseName $params.databaseName
100+
Assert-AreEqual $importResponse.StorageKeyType $params.storageKeyType
101+
Assert-Null $importResponse.StorageKey
102+
Assert-AreEqual $importResponse.StorageUri $params.importBacpacUri
103+
Assert-AreEqual $importResponse.AdministratorLogin $params.userName
104+
Assert-Null $importResponse.AdministratorLoginPassword
105+
Assert-AreEqual $importResponse.AuthenticationType $params.authType
106+
Assert-AreEqual $importResponse.Edition $params.databaseEdition
107+
Assert-AreEqual $importResponse.ServiceObjectiveName $params.serviceObjectiveName
108+
Assert-AreEqual $importResponse.DatabaseMaxSizeBytes $params.databaseMaxSizeBytes
88109
}
89110

90111
Assert-NotNull $operationStatusLink
@@ -98,8 +119,14 @@ function Test-ImportDatabase
98119
Write-Output "Getting Status"
99120
while($status -eq $statusInProgress){
100121
$statusResponse = Get-AzureRmSqlDatabaseImportExportStatus -OperationStatusLink $operationStatusLink
101-
Write-Output "Import Export Status Message:" + $statusResponse.StatusMessage
122+
Write-Output "Import Export Status Message:" + $statusResponse.StatusMessage
123+
Assert-AreEqual $statusResponse.OperationStatusLink $operationStatusLink
102124
$status = $statusResponse.Status
125+
if($status -eq $statusInProgress){
126+
Assert-NotNull $statusResponse.LastModifiedTime
127+
Assert-NotNull $statusResponse.QueuedTime
128+
Assert-NotNull $statusResponse.StatusMessage
129+
}
103130
}
104131
Assert-AreEqual $status $statusSucceeded
105132
Write-Output "ImportExportStatus:" + $status

src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/SqlTestsBase.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ protected void RunPowerShellTest(params string[] scripts)
8484
"ScenarioTests\\" + this.GetType().Name + ".ps1",
8585
helper.RMProfileModule,
8686
helper.RMResourceModule,
87-
helper.RMStorageDataPlaneModule,
88-
helper.RMStorageModule,
87+
helper.RMStorageDataPlaneModule,
8988
helper.GetRMModulePath(@"AzureRM.Insights.psd1"),
90-
helper.GetRMModulePath(@"AzureRM.Sql.psd1"));
89+
helper.GetRMModulePath(@"AzureRM.Sql.psd1"),
90+
"AzureRM.Storage.ps1");
9191
helper.RunPowerShellTest(scripts);
9292
}
9393
}

src/ResourceManager/Sql/Commands.Sql/ImportExport/Model/AzureSqlDatabaseImportExportBaseModel.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,22 @@ public string OperationStatusLink
109109
/// Gets or sets the error message returned from the server.
110110
/// </summary>
111111
public string ErrorMessage { get; set; }
112+
113+
/// <summary>
114+
/// Copies the model to a new class
115+
/// </summary>
116+
internal virtual AzureSqlDatabaseImportExportBaseModel Copy()
117+
{
118+
return new AzureSqlDatabaseImportExportBaseModel()
119+
{
120+
ResourceGroupName = ResourceGroupName,
121+
ServerName = ServerName,
122+
AdministratorLogin = AdministratorLogin,
123+
AuthenticationType = AuthenticationType,
124+
DatabaseName = DatabaseName,
125+
StorageKeyType = StorageKeyType,
126+
StorageUri = StorageUri
127+
};
128+
}
112129
}
113130
}

src/ResourceManager/Sql/Commands.Sql/ImportExport/Model/AzureSqlDatabaseImportModel.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,26 @@ public string ServiceObjectiveName
4848
public int DatabaseMaxSizeBytes
4949
{
5050
get; set;
51-
}
51+
}
52+
53+
/// <summary>
54+
/// Copies the model to a new class
55+
/// </summary>
56+
internal override AzureSqlDatabaseImportExportBaseModel Copy()
57+
{
58+
return new AzureSqlDatabaseImportModel()
59+
{
60+
ResourceGroupName = ResourceGroupName,
61+
ServerName = ServerName,
62+
AdministratorLogin = AdministratorLogin,
63+
AuthenticationType = AuthenticationType,
64+
DatabaseName = DatabaseName,
65+
StorageKeyType = StorageKeyType,
66+
StorageUri = StorageUri,
67+
Edition = Edition,
68+
ServiceObjectiveName = ServiceObjectiveName,
69+
DatabaseMaxSizeBytes = DatabaseMaxSizeBytes
70+
};
71+
}
5272
}
5373
}

0 commit comments

Comments
 (0)