0
votes

How to check if Microsoft Azure KeyVault exist? I am creating with the following script via PowerShell a new KeyVault

$vaultName = "kv3"
Set-AzureRmContext -Subscription "yyyy-f48c-4e0c-80f4-cxxxx"

New-AzureRmKeyVault -VaultName $vaultName -ResourceGroupName 'bogl' -Location 'North Europe'

$secretvalue = ConvertTo-SecureString '4444' -AsPlainText -Force
$secret = Set-AzureKeyVaultSecret -VaultName $vaultName -Name 'mySecret' -SecretValue $secretvalue

--> Check if KeyVault was successfully created/deployment process was finished or wait ...

$status = Get-AzureRMKeyVault -VaultName $vaultName
Write-Host $status

When KeyVault deployment process takes a little bit longer and the KeyVault is not yet available, then i want to wait some seconds.

1

1 Answers

0
votes

you can put a simple loop that will test whether the KV is created -

while (-not (Get-AzureRmKeyVault -VaultName "test-keyvault" ))
{
   sleep 10
}