-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInvokeAzResourceOps.ps1
30 lines (25 loc) · 1.02 KB
/
InvokeAzResourceOps.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
#!/usr/bin/pwsh
'Prepare modules.'
[string[]] $Modules = @(
'Az.Accounts',
'Az.Resources'
)
$null = Install-Module -Name $Modules -Scope 'CurrentUser' -Force
$null = Import-Module ('.\{0}\src\AzResourceOps.psd1' -f $env:AZRESOURCEOPS_REPO_NAME)
if (Get-Module -Name 'AzResourceOps') {
'Connecting to Azure.'
[pscustomobject] $CredentialObject = ($env:AZURE_CREDENTIALS | ConvertFrom-Json)
[pscredential] $Credential = [pscredential]::new($CredentialObject.clientId, ($CredentialObject.clientSecret | ConvertTo-SecureString -AsPlainText -Force))
[hashtable] $ConnectionParameters = @{
TenantId = $CredentialObject.tenantId
ServicePrincipal = $true
Credential = $Credential
SubscriptionId = $CredentialObject.subscriptionId
WarningAction = 'SilentlyContinue'
}
$null = Connect-AzAccount @ConnectionParameters
'Initiating deployment.'
New-AzResOpsSubscriptionDeployment
'Cleaning up repository.'
Invoke-AzResOpsCleanRepository
}