-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy.ps1
More file actions
44 lines (34 loc) · 1.23 KB
/
deploy.ps1
File metadata and controls
44 lines (34 loc) · 1.23 KB
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
param (
[Parameter(Mandatory=$true)]
[string]$subscriptionId,
[Parameter(Mandatory=$true)]
[string]$resourceGroupName,
[Parameter(Mandatory=$true)]
[string]$developerUserName,
[Parameter(Mandatory=$true)]
[string]$location
)
# Define variables
$templateFile = "./deploy/deployAll.bicep"
$deploymentName = "sample-app-deployment"
# Read SQL admin password from environment variable
$sqlAdminPassword = $env:SQL_ADMIN_PASSWORD
# Check if SQL admin password exists
if (-not $sqlAdminPassword) {
Write-Error "SQL admin password is not set in the environment variable SQL_ADMIN_PASSWORD."
exit 1
}
# Login to Azure
az account set --subscription $subscriptionId
# Check if resource group exists
$resourceGroup = az group show --name $resourceGroupName --query "name" --output tsv
# Create resource group if it doesn't exist
if (-not $resourceGroup) {
az group create --name $resourceGroupName --location $location
}
# Deploy the Bicep template
az deployment group create `
--name $deploymentName `
--resource-group $resourceGroupName `
--template-file $templateFile `
--parameters developerUsername=$developerUserName sqlAdminPassword=$sqlAdminPassword