Created
July 24, 2018 01:53
-
-
Save marckean/ee81125724af053ab5f6f29d24f7ba4a to your computer and use it in GitHub Desktop.
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
# Login to Azure manually | |
Clear-AzureRmContext -Scope CurrentUser -Force | |
Login-AzureRmAccount -TenantId '<Your Azure Tenant ID>' # Microsoft | |
### Choose Subscription | |
$subscription = Get-AzureRmSubscription | Out-GridView -Title "Select the Azure subscription that you want to use ..." -PassThru | |
Select-AzureRmSubscription -SubscriptionId $subscription.id | |
# Fill in these variables | |
$StorageAccountName = '<YourStorageAccountName>' | |
$StorageContainerName = '<YourStorageContainerName>' | |
$StorageAccountKey = '<YourStorageAccountKey>' | |
$BlobName = '/SomeFolder/file.ext' # this is to construct the SAS URI below so you can test | |
$StgContext = New-AzureStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $StorageAccountKey | |
$StartTime = Get-Date | |
$EndTime = $startTime.AddHours(5.0) | |
# Read access - https://docs.microsoft.com/en-us/powershell/module/azure.storage/new-azurestoragecontainersastoken | |
$SasToken = New-AzureStorageContainerSASToken -Name $StorageContainerName ` | |
-Context $StgContext -Permission rl -StartTime $StartTime -ExpiryTime $EndTime | |
$SasToken | clip | |
# Construnct the URL & Test | |
$url = "$($StgContext.BlobEndPoint)$($StorageContainerName)$($BlobName)$($SasToken)" | |
$url | clip | |
Invoke-WebRequest -UseBasicParsing -Uri $url | Out-Null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment