-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeploy-Infrastructure.ps1
41 lines (34 loc) · 1.44 KB
/
Deploy-Infrastructure.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
<#
.SYNOPSIS
Deploys the core infrastructure for the AI Document Pipeline to an Azure subscription.
.DESCRIPTION
This script initiates the deployment of the main.bicep template to the current default Azure subscription,
determined by the Azure CLI. The deployment name and location are required parameters.
.PARAMETER DeploymentName
The name of the deployment to create in an Azure subscription.
.PARAMETER Location
The location to deploy the Azure resources to.
.EXAMPLE
.\Deploy-Infrastructure.ps1 -DeploymentName "my-workflows" -Location "westeurope"
.NOTES
Author: James Croft
#>
param
(
[Parameter(Mandatory = $true)]
[string]$DeploymentName,
[Parameter(Mandatory = $true)]
[string]$Location
)
Write-Host "Starting infrastructure deployment..."
Push-Location -Path $PSScriptRoot
$UserPrincipalId = ((az rest --method GET --uri "https://graph.microsoft.com/v1.0/me") | ConvertFrom-Json).id
$DeploymentOutputs = (az deployment sub create --name $DeploymentName --location $Location --template-file './main.bicep' `
--parameters './main.parameters.json' `
--parameters workloadName=$DeploymentName `
--parameters location=$Location `
--parameters userPrincipalId=$UserPrincipalId `
--query properties.outputs -o json) | ConvertFrom-Json
$DeploymentOutputs | ConvertTo-Json | Out-File -FilePath './InfrastructureOutputs.json' -Encoding utf8
Pop-Location
return $DeploymentOutputs