-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCall-PutDataFile.ps1
26 lines (20 loc) · 963 Bytes
/
Call-PutDataFile.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
26
<#
This script calls the Azure Blob Storage API to upload a file.
You need to have a valid settings file and data file for this script to work
This script is tested in PowerShell Core 7
#>
## initialise script
$configFile = ".\settings.json"
$conf = Get-Content $configFile | ConvertFrom-Json
## initialise http request
$uri = $conf.blob.sasUriRoot + "/batch/" + $conf.var.latestWorkingFolderId + "/" + $conf.local.inputFilename + $conf.blob.sasUriAuth
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("Accept", "application/json")
$headers.Add("x-ms-blob-type", "BlockBlob")
$body = Get-Content ("./data/" + $conf.local.inputFileName)
## Execute http request
$response = Invoke-WebRequest $uri -Method 'PUT' -Headers $headers -Body $body
Write-Output $response | Format-List -Property StatusCode, StatusDescription
# Pause
#Read-Host "Press Enter to continue..."