forked from microsoft/dotnet-podcasts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeploy-Images.ps1
29 lines (20 loc) · 1.06 KB
/
Deploy-Images.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
27
28
29
#! /usr/bin/pwsh
Param(
[parameter(Mandatory=$true)][string]$resourceGroup,
[parameter(Mandatory=$true)][string]$storageName
)
$storage = $(az storage account show -n $storageName -g $resourceGroup -o json | ConvertFrom-Json)
if (-not $storage) {
Write-Host "Storage $storageName not found in RG $resourceGroup" -ForegroundColor Red
exit 1
}
$url = $storage.primaryEndpoints.blob
$constr = $(az storage account show-connection-string -n $storageName -g $resourceGroup -o json | ConvertFrom-Json).connectionString
$containerExists = $(az storage container exists --name "covers" --connection-string "$constr" | ConvertFrom-Json).exists
if (!$containerExists) {
Write-Host "Connecting to storage and creating containers" -ForegroundColor Green
az storage container create --name "covers" --public-access blob --connection-string "$constr"
Write-Host "Copying images..." -ForegroundColor Green
$accountName=$storage.name
az storage blob upload-batch --destination "$url" --destination covers --source ./Covers --account-name $accountName
}