forked from Azure/azure-powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add script storage module to remove test setup dependencies on storage cmdlets #1
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ba4c668
Adding script cmdlets for managing storage accounts. This will repla…
markcowl de5e01a
Merge branch 'dev' of github.com:wastoresh/azure-powershell into stor…
markcowl f888e20
Update script storage new-azurermstorageaccount implementation to rem…
markcowl 5081dac
Update script storage new-azurermstorageaccount implementation to rem…
markcowl fc1e525
Merge branch 'storageversions' of github.com:markcowl/azure-powershel…
markcowl 6ad0a4c
Adding new storage test cmdlets to Sql tests
markcowl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be removed?