Last active
August 29, 2015 14:03
-
-
Save codingoutloud/f3c74eeceb84f2f7ae15 to your computer and use it in GitHub Desktop.
Formats the output from Get-AzureStorageKey as a connection string.
This file contains hidden or 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
| Function Format-AzureStorageKey { | |
| [CmdletBinding()] | |
| Param ( | |
| [parameter(Mandatory=$True,ValueFromPipelineByPropertyName=$True)] | |
| [string[]] $Primary, | |
| [parameter(Mandatory=$True,ValueFromPipelineByPropertyName=$True)] | |
| [string[]] $Secondary, | |
| [parameter(Mandatory=$True,ValueFromPipelineByPropertyName=$True)] | |
| [string[]] $StorageAccountName, | |
| [switch] $AsConnectionString, # noop since is really only current option | |
| [switch] $UseSecondary, | |
| [switch] $UseHttp | |
| # Not providing UsePrimary or UseHttps switches since they are defaults | |
| # Consider adding support for proxies and specific services: | |
| # http://msdn.microsoft.com/en-us/library/azure/ee758697.aspx | |
| ) | |
| if ($UseSecondary) { | |
| $key = $Secondary | |
| } | |
| else { | |
| $key = $Primary | |
| } | |
| if ($UseHttp) { | |
| $protocol = "http" | |
| } | |
| else { | |
| $protocol = "https" | |
| } | |
| Write-Host "DefaultEndpointsProtocol=$protocol;AccountName=$StorageAccountName;AccountKey=$key" | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage Setup:
Usage:
Output:
bcE52sidWQbCXoxidpn6ZROL20GFVj+Ulc3X7+GbemcWOlYK6sUycAJJqmJaQ0KnQ==
bcE52sidWQbCXoxidpn6ZROL20GFVj+Ulc3X7+GbemcWOlYK6sUycAJJqmJaQ0KnQ==
Z/blgG9lygTIKCBXeT3q8K6RaXCC0Xqrm3M3zm6+SiULrY+dbFdTyOl+KmsHqcJg==
Resources: