-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstaging.ps
47 lines (36 loc) · 1.41 KB
/
staging.ps
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# set mac file path -- need help to do this more securely
$filePath = "\users\daniel\repo\AzureChallenge\"
# code source:
# https://docs.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-powershell
# login manually to Azure ** dont store credentials insecurely **
Login-AzureRmAccount
# provision in case of multiple subscriptions
# Select-AzureRmSubscription -SubscriptionId "<SubscriptionId>"
# create the Azure resource group
$resourceGroup = "AzureChallengeResourceGroup";
$location = "AustraliaEast"
New-AzureRmResourceGroup $resourceGroup $location
# create storage account
$storageAccount = New-AzureRmStorageAccount -ResourceGroupName $resourceGroup `
-Name "AxureChallengeStorageAccount" `
-Location $location `
-SkuName Standard_LRS `
-Kind Storage
$ctx = $storageAccount.Context
# create blob container
$containerName = "AzureChallengeBlob"
New-AzureStorageContainer -Name $containerName -Context $ctx -Permission blob
# upload a customer file
$file = $filePath & "customer.csv"
Set-AzureStorageBlobContent -File $file`
-Container $containerName `
-Blob "customer.csv" `
-Context $ctx
# upload order file
$file = $filePath & "order.csv"
Set-AzureStorageBlobContent -File $file `
-Container $containerName `
-Blob "order.csv" `
-Context $ctx
# list blobs in container -- ideally return true/false test result
Get-AzureStorageBlob -Container $ContainerName -Context $ctx | select Name