-
Notifications
You must be signed in to change notification settings - Fork 123
/
Copy pathcreate-cert.ps1
25 lines (19 loc) · 940 Bytes
/
create-cert.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
param(
[string] [Parameter(Mandatory=$false)] $vaultName,
[string] [Parameter(Mandatory=$false)] $certificateName,
[string] [Parameter(Mandatory=$false)] $subjectName
)
$ErrorActionPreference = 'Stop'
$policy = New-AzKeyVaultCertificatePolicy -SubjectName $subjectName -IssuerName Self -ValidityInMonths 12 -Verbose
# private key is added as a secret that can be retrieved in the ARM template
Add-AzKeyVaultCertificate -VaultName $vaultName -Name $certificateName -CertificatePolicy $policy -Verbose
$cert = Get-AzKeyVaultCertificate -VaultName $vaultName -Name $certificateName
# it take a few seconds for KeyVault to finish
while($cert.Thumbprint -eq $null){
Write-Output 'Sleeping...'
Start-Sleep 5
$cert = Get-AzKeyVaultCertificate -VaultName $vaultName -Name $certificateName
}
$DeploymentScriptOutputs = New-Object -TypeName hashtable
$DeploymentScriptOutputs['certThumbprint'] = $cert.Thumbprint
$cert | Out-String