forked from Azure/azure-powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from markcowl/storageversions
Add script storage module to remove test setup dependencies on storage cmdlets
- Loading branch information
Showing
9 changed files
with
134 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/AzureRM.Storage.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters