forked from microsoft/azure-api-management-monetization
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.ps1
51 lines (38 loc) · 1.74 KB
/
deploy.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[string]
$TenantId,
[Parameter(Mandatory=$true)]
[string]
$SubscriptionId,
[Parameter(Mandatory=$true)]
[string]
$ResourceGroupName,
[Parameter(Mandatory=$true)]
[string]
$ResourceGroupLocation,
[Parameter(Mandatory=$true)]
[string]
$ArtifactStorageAccountName,
[Parameter()]
[string]
$ParameterFilePath = "$(Split-Path -Parent $PSCommandPath)/output/main.parameters.json"
)
$ErrorActionPreference = "Stop"
$here = Split-Path -Parent $PSCommandPath
$deploymentName = "apim-monetization-{0}" -f (Get-Date).ToString("yyyyMMddHHmmss")
$account = (az account show) | ConvertFrom-Json
if (!$account -or $account.tenantId -ne $TenantId) {
az login --tenant $TenantId
}
if ($account.id -ne $SubscriptionId) {
az account set --subscription $SubscriptionId
}
az group create --name $ResourceGroupName --location $ResourceGroupLocation
az storage account create -n $ArtifactStorageAccountName -g $ResourceGroupName -l $ResourceGroupLocation
az storage container create -n default --account-name $ArtifactStorageAccountName --public-access blob
az storage blob directory upload -c default --account-name $ArtifactStorageAccountName -s "$here/apiConfiguration/*" -d "/apiConfiguration" --recursive
az storage blob directory upload -c default --account-name $ArtifactStorageAccountName -s "$here/payment/*" -d "/payment" --recursive
$artifactsBaseUrl = "https://$ArtifactStorageAccountName.blob.core.windows.net/default"
az deployment group create --resource-group $ResourceGroupName --name $deploymentName --template-file "$here/output/main.json" --parameters (Resolve-Path $ParameterFilePath) --parameters artifactsBaseUrl=$artifactsBaseUrl