To retrieve URL of a new Azure Key Vault, you will need to create a Vault
using the azure-native.keyvault.Vault
resource. The vault URI is not an explicit output property of this resource, but it can be constructed from the other output properties of the Vault.
You would create Azure Key Vault in a specified resource group and location, and once the vault is created, you can construct the URL by using its DNS name which follows this pattern: https://<vault-name>.vault.azure.net/
.
Here's how you can do this in a Pulumi program:
import * as azure from "@pulumi/azure-native";// Create an Azure Resource Groupconst resourceGroup = new azure.resources.ResourceGroup("resourceGroup", { resourceGroupName: "rg", location: "westus",});// Create an Azure Key Vaultconst vault = new azure.keyvault.Vault("myVault", { resourceGroupName: resourceGroup.name, vaultName: "myVault", location: resourceGroup.location, properties: { sku: { family: "A", name: "standard", }, tenantId: "<insert your tenantId>", accessPolicies: [], },});// Retrieve the KeyVault URLexport const vaultUri = vault.properties.apply(properties => `https://${properties.vaultUri}.vault.azure.net/`);
In this program:
- We're first creating a new Azure resource group using the
azure.resources.ResourceGroup
resource. - Then, we're creating the Azure Key Vault in this resource group, using
azure-native.keyvault.Vault
. The accessPolicies is set as an empty array to indicate no access policies are set on creation. - Lastly, we output the URL of the created vault through the
vaultUri
which can be accessed usingpulumi stack output vaultUri
.
Ensure to replace <insert your tenantId>
with your actual Azure Tenant ID.