-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenerate-sas-token.ps1
25 lines (16 loc) · 1.04 KB
/
Generate-sas-token.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
$AzureRmSubscriptionName = (Get-AzureRmContext).Subscription.SubscriptionName
Select-AzureRmSubscription -SubscriptionName $AzureRmSubscriptionName
$AzureResourceGroupName = "some-rg"
$AzureStorageAccountName = "somesa"
$AzureStorageContainerName = "somecontainer"
$Keys = Get-AzureRmStorageAccountKey -ResourceGroupName $AzureResourceGroupName -StorageAccountName $AzureStorageAccountName
$StorageAccountKey = $Keys[0].Value
$storageContext = New-AzureStorageContext -StorageAccountName $AzureStorageAccountName -StorageAccountKey $StorageAccountKey
$now=get-date
$sastoken = New-AzureStorageContainerSASToken -Name $AzureStorageContainerName -Context $storageContext -Permission rl -StartTime $now.AddHours(-1) -ExpiryTime $now.AddMonths(1)
$sastoken
$storageuri = "https://$AzureStorageAccountName.blob.core.windows.net/$AzureStorageContainerName"
$url = $storageUri + "/Import-export-storage-table-module.psm1" + $sastoken
$output = "d:/tmp/Import-export-storage-table-module.psm1"
(New-Object System.Net.WebClient).DownloadFile($url, $output)