# AzureKeyVaultResourceExtensions

- Kind: `class`
- Package: [Aspire.Hosting.Azure.KeyVault](/reference/api/csharp/aspire.hosting.azure.keyvault.md)
- Version: `13.4.0`
- Namespace: `Aspire.Hosting`
- Target framework: `net8.0`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.KeyVault/AzureKeyVaultResourceExtensions.cs)

Provides extension methods for adding the Azure Key Vault resources to the application model.

## Definition

```csharp
namespace Aspire.Hosting;

public static class AzureKeyVaultResourceExtensions
{
    // ...
}
```

## Methods

- [AddAzureKeyVault(IDistributedApplicationBuilder, string)](/reference/api/csharp/aspire.hosting.azure.keyvault/azurekeyvaultresourceextensions/methods.md#addazurekeyvault-idistributedapplicationbuilder-string) : `IResourceBuilder<AzureKeyVaultResource>` `extension` `ats export` -- Adds an Azure Key Vault resource to the application model.
- [AddSecret(IResourceBuilder<AzureKeyVaultResource>, string, IResourceBuilder<ParameterResource>)](/reference/api/csharp/aspire.hosting.azure.keyvault/azurekeyvaultresourceextensions/methods.md#addsecret-iresourcebuilder-azurekeyvaultresource-string-iresourcebuilder-parameterresource) : `IResourceBuilder<AzureKeyVaultSecretResource>` `extension` `ats ignored` -- Adds a secret to the Azure Key Vault resource with the value from a parameter resource.
- [AddSecret(IResourceBuilder<AzureKeyVaultResource>, string, ParameterResource)](/reference/api/csharp/aspire.hosting.azure.keyvault/azurekeyvaultresourceextensions/methods.md#addsecret-iresourcebuilder-azurekeyvaultresource-string-parameterresource) : `IResourceBuilder<AzureKeyVaultSecretResource>` `extension` `ats ignored` -- Adds a secret to the Azure Key Vault resource with the value from a parameter resource.
- [AddSecret(IResourceBuilder<AzureKeyVaultResource>, string, ReferenceExpression)](/reference/api/csharp/aspire.hosting.azure.keyvault/azurekeyvaultresourceextensions/methods.md#addsecret-iresourcebuilder-azurekeyvaultresource-string-referenceexpression) : `IResourceBuilder<AzureKeyVaultSecretResource>` `extension` `ats ignored` -- Adds a secret to the Azure Key Vault resource with the value from a reference expression.
- [AddSecret(IResourceBuilder<AzureKeyVaultResource>, string, string, IResourceBuilder<ParameterResource>)](/reference/api/csharp/aspire.hosting.azure.keyvault/azurekeyvaultresourceextensions/methods.md#addsecret-iresourcebuilder-azurekeyvaultresource-string-string-iresourcebuilder-parameterresource) : `IResourceBuilder<AzureKeyVaultSecretResource>` `extension` `ats ignored` -- Adds a secret to the Azure Key Vault resource with the value from a parameter resource.
- [AddSecret(IResourceBuilder<AzureKeyVaultResource>, string, string, ParameterResource)](/reference/api/csharp/aspire.hosting.azure.keyvault/azurekeyvaultresourceextensions/methods.md#addsecret-iresourcebuilder-azurekeyvaultresource-string-string-parameterresource) : `IResourceBuilder<AzureKeyVaultSecretResource>` `extension` `ats ignored` -- Adds a secret to the Azure Key Vault resource with the value from a parameter resource.
- [AddSecret(IResourceBuilder<AzureKeyVaultResource>, string, string, ReferenceExpression)](/reference/api/csharp/aspire.hosting.azure.keyvault/azurekeyvaultresourceextensions/methods.md#addsecret-iresourcebuilder-azurekeyvaultresource-string-string-referenceexpression) : `IResourceBuilder<AzureKeyVaultSecretResource>` `extension` `ats ignored` -- Adds a secret to the Azure Key Vault resource with the value from a reference expression.
- [GetSecret(IResourceBuilder<AzureKeyVaultResource>, string)](/reference/api/csharp/aspire.hosting.azure.keyvault/azurekeyvaultresourceextensions/methods.md#getsecret-iresourcebuilder-azurekeyvaultresource-string) : `IAzureKeyVaultSecretReference` `extension` `ats export` -- Gets a secret reference for the specified secret name from the Azure Key Vault resource.
- [WithRoleAssignments(IResourceBuilder<T>, IResourceBuilder<AzureKeyVaultResource>, KeyVaultBuiltInRole[])](/reference/api/csharp/aspire.hosting.azure.keyvault/azurekeyvaultresourceextensions/methods.md#withroleassignments-iresourcebuilder-t-iresourcebuilder-azurekeyvaultresource-keyvaultbuiltinrole) : `IResourceBuilder<T>` `extension` `ats ignored` -- Assigns the specified roles to the given resource, granting it the necessary permissions on the target Azure Key Vault resource. This replaces the default role assignments for the resource.
