diff --git a/src/ResourceManager/ApiManagement/Commands.ApiManagement.Test/Commands.ApiManagement.Test.csproj b/src/ResourceManager/ApiManagement/Commands.ApiManagement.Test/Commands.ApiManagement.Test.csproj index e06a81507ac9..e9fa4d58c8ed 100644 --- a/src/ResourceManager/ApiManagement/Commands.ApiManagement.Test/Commands.ApiManagement.Test.csproj +++ b/src/ResourceManager/ApiManagement/Commands.ApiManagement.Test/Commands.ApiManagement.Test.csproj @@ -179,6 +179,9 @@ + + ScenarioTests\AzureRM.Storage.ps1 + Designer diff --git a/src/ResourceManager/ApiManagement/Commands.ApiManagement.Test/ScenarioTests/ApiManagementTests.cs b/src/ResourceManager/ApiManagement/Commands.ApiManagement.Test/ScenarioTests/ApiManagementTests.cs index a94bf613d8ae..25027f05610b 100644 --- a/src/ResourceManager/ApiManagement/Commands.ApiManagement.Test/ScenarioTests/ApiManagementTests.cs +++ b/src/ResourceManager/ApiManagement/Commands.ApiManagement.Test/ScenarioTests/ApiManagementTests.cs @@ -176,8 +176,8 @@ private void RunPowerShellTest(params string[] scripts) _helper.RMProfileModule, _helper.RMResourceModule, _helper.RMStorageDataPlaneModule, - _helper.RMStorageModule, - _helper.GetRMModulePath("AzureRM.ApiManagement.psd1")); + _helper.GetRMModulePath("AzureRM.ApiManagement.psd1"), + "AzureRM.Storage.ps1"); _helper.RunPowerShellTest(scripts); } diff --git a/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/AzureRM.Storage.ps1 b/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/AzureRM.Storage.ps1 new file mode 100644 index 000000000000..09d28064ae10 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/AzureRM.Storage.ps1 @@ -0,0 +1,113 @@ + +function Get-AzureRmStorageAccount +{ + + [CmdletBinding()] + param( + [string] [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)] $ResourceGroupName, + [string] [Parameter(Position=1, ValueFromPipelineByPropertyName=$true)] [alias("StorageAccountName")] $Name) + BEGIN { + $context = Get-Context + $client = Get-StorageClient $context + } + PROCESS { + $getTask = $client.StorageAccounts.GetPropertiesAsync($ResourceGroupName, $name, [System.Threading.CancellationToken]::None) + $sa = $getTask.Result + $account = Get-StorageAccount $ResourceGroupName $Name + Write-Output $account + } + END {} + +} + +function New-AzureRmStorageAccount +{ + [CmdletBinding()] + param( + [string] [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)] $ResourceGroupName, + [string] [Parameter(Position=1, ValueFromPipelineByPropertyName=$true)][alias("StorageAccountName")] $Name, + [string] [Parameter(Position=2, ValueFromPipelineByPropertyName=$true)] $Location, + [string] [Parameter(Position=3, ValueFromPipelineByPropertyName=$true)] $Type) + BEGIN { + $context = Get-Context + $client = Get-StorageClient $context + } + PROCESS { + $createParms = New-Object -Type Microsoft.Azure.Management.Storage.Models.StorageAccountCreateParameters + $createParms.AccountType = [Microsoft.Azure.Management.Storage.Models.AccountType]::StandardLRS + $createParms.Location = $Location + $getTask = $client.StorageAccounts.CreateAsync($ResourceGroupName, $name, $createParms, [System.Threading.CancellationToken]::None) + $sa = $getTask.Result + } + END {} + +} + +function Get-AzureRmStorageAccountKey +{ + [CmdletBinding()] + param( + [string] [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)] $ResourceGroupName, + [string] [Parameter(Position=1, ValueFromPipelineByPropertyName=$true)] [alias("StorageAccountName")] $Name) + BEGIN { + $context = Get-Context + $client = Get-StorageClient $context + } + PROCESS { + $getTask = $client.StorageAccounts.ListKeysAsync($ResourceGroupName, $name, [System.Threading.CancellationToken]::None) + Write-Output $getTask.Result.StorageAccountKeys + } + END {} +} + +function Remove-AzureRmStorageAccount +{ + + [CmdletBinding()] + param( + [string] [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)] $ResourceGroupName, + [string] [Parameter(Position=1, ValueFromPipelineByPropertyName=$true)] [alias("StorageAccountName")] $Name) + BEGIN { + $context = Get-Context + $client = Get-StorageClient $context + } + PROCESS { + $getTask = $client.StorageAccounts.DeleteAsync($ResourceGroupName, $name, [System.Threading.CancellationToken]::None) + $sa = $getTask.Result + } + END {} + +} + +function Get-Context +{ + [Microsoft.Azure.Commands.Common.Authentication.Models.AzureContext]$context = $null + $profile = [Microsoft.WindowsAzure.Commands.Common.AzureRmProfileProvider]::Instance.Profile + if ($profile -ne $null) + { + $context = $profile.Context + } + + return $context +} + +function Get-StorageClient +{ + param([Microsoft.Azure.Commands.Common.Authentication.Models.AzureContext] $context) + $factory = [Microsoft.Azure.Commands.Common.Authentication.AzureSession]::ClientFactory + [System.Type[]]$types = [Microsoft.Azure.Commands.Common.Authentication.Models.AzureContext], [Microsoft.Azure.Commands.Common.Authentication.Models.AzureEnvironment+Endpoint] + $method = [Microsoft.Azure.Commands.Common.Authentication.IClientFactory].GetMethod("CreateClient", $types) + $closedMethod = $method.MakeGenericMethod([Microsoft.Azure.Management.Storage.StorageManagementClient]) + $arguments = $context, [Microsoft.Azure.Commands.Common.Authentication.Models.AzureEnvironment+Endpoint]::ResourceManager + $client = $closedMethod.Invoke($factory, $arguments) + return $client +} + +function Get-StorageAccount { + param([string] $resourceGroupName, [string] $name) + $endpoints = New-Object PSObject -Property @{"Blob" = "https://$name.blob.core.windows.net/"} + $sa = New-Object PSObject -Property @{"Name" = $name; "ResourceGroupName" = $resourceGroupName; + "PrimaryEndpoints" = $endpoints + } + return $sa +} \ No newline at end of file diff --git a/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/Commands.ScenarioTests.ResourceManager.Common.csproj b/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/Commands.ScenarioTests.ResourceManager.Common.csproj index 815d16b3a4cc..d7be705b67c1 100644 --- a/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/Commands.ScenarioTests.ResourceManager.Common.csproj +++ b/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/Commands.ScenarioTests.ResourceManager.Common.csproj @@ -161,6 +161,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/src/ResourceManager/Compute/Commands.Compute.Test/Commands.Compute.Test.csproj b/src/ResourceManager/Compute/Commands.Compute.Test/Commands.Compute.Test.csproj index 1ae988957a3d..05d9f8ef9377 100644 --- a/src/ResourceManager/Compute/Commands.Compute.Test/Commands.Compute.Test.csproj +++ b/src/ResourceManager/Compute/Commands.Compute.Test/Commands.Compute.Test.csproj @@ -218,6 +218,9 @@ ScenarioTests\Assert.ps1 Always + + ScenarioTests\AzureRM.Storage.ps1 + ScenarioTests\Common.ps1 Always diff --git a/src/ResourceManager/Compute/Commands.Compute.Test/Common/ComputeTestController.cs b/src/ResourceManager/Compute/Commands.Compute.Test/Common/ComputeTestController.cs index 3b54e6c3316b..960b475f5ed3 100644 --- a/src/ResourceManager/Compute/Commands.Compute.Test/Common/ComputeTestController.cs +++ b/src/ResourceManager/Compute/Commands.Compute.Test/Common/ComputeTestController.cs @@ -134,7 +134,8 @@ public void RunPsTestWorkflow( helper.RMStorageDataPlaneModule, helper.RMStorageModule, helper.GetRMModulePath("AzureRM.Compute.psd1"), - helper.GetRMModulePath("AzureRM.Network.psd1")); + helper.GetRMModulePath("AzureRM.Network.psd1"), + "AzureRM.Storage.ps1"); try { diff --git a/src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/SqlTestsBase.cs b/src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/SqlTestsBase.cs index bcafc3ff177c..4822c5809178 100644 --- a/src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/SqlTestsBase.cs +++ b/src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/SqlTestsBase.cs @@ -84,10 +84,10 @@ protected void RunPowerShellTest(params string[] scripts) "ScenarioTests\\" + this.GetType().Name + ".ps1", helper.RMProfileModule, helper.RMResourceModule, - helper.RMStorageDataPlaneModule, - helper.RMStorageModule, + helper.RMStorageDataPlaneModule, helper.GetRMModulePath(@"AzureRM.Insights.psd1"), - helper.GetRMModulePath(@"AzureRM.Sql.psd1")); + helper.GetRMModulePath(@"AzureRM.Sql.psd1"), + "AzureRM.Storage.ps1"); helper.RunPowerShellTest(scripts); } } diff --git a/src/ResourceManager/Websites/Commands.Websites.Test/Commands.Websites.Test.csproj b/src/ResourceManager/Websites/Commands.Websites.Test/Commands.Websites.Test.csproj index a1e20507e00c..b4fe34e39cb2 100644 --- a/src/ResourceManager/Websites/Commands.Websites.Test/Commands.Websites.Test.csproj +++ b/src/ResourceManager/Websites/Commands.Websites.Test/Commands.Websites.Test.csproj @@ -152,6 +152,9 @@ + + ScenarioTests\AzureRM.Storage.ps1 + Designer @@ -304,10 +307,6 @@ {e1f5201d-6067-430e-b303-4e367652991b} Commands.Resources - - {a50ab133-5c04-4a17-9054-f8343683ec23} - Commands.Management.Storage - {80a92297-7c92-456b-8ee7-9fb6ce30149d} Commands.Websites diff --git a/src/ResourceManager/Websites/Commands.Websites.Test/ScenarioTests/WebsitesController.cs b/src/ResourceManager/Websites/Commands.Websites.Test/ScenarioTests/WebsitesController.cs index f30b2b77530c..156269c247f9 100644 --- a/src/ResourceManager/Websites/Commands.Websites.Test/ScenarioTests/WebsitesController.cs +++ b/src/ResourceManager/Websites/Commands.Websites.Test/ScenarioTests/WebsitesController.cs @@ -117,9 +117,9 @@ public void RunPsTestWorkflow( "ScenarioTests\\" + callingClassName + ".ps1", helper.RMProfileModule, helper.RMStorageDataPlaneModule, - helper.RMStorageModule, helper.RMResourceModule, - helper.GetRMModulePath(@"AzureRM.WebSites.psd1")); + helper.GetRMModulePath(@"AzureRM.WebSites.psd1"), + "AzureRM.Storage.ps1"); try {