# AzureProvisioningResourceExtensions Methods

- Package: [Aspire.Hosting.Azure](/reference/api/csharp/aspire.hosting.azure.md)
- Type: [AzureProvisioningResourceExtensions](/reference/api/csharp/aspire.hosting.azure/azureprovisioningresourceextensions.md)
- Kind: `Methods`
- Members: `9`

Extensions for working with [AzureProvisioningResource](/reference/api/csharp/aspire.hosting.azure/azureprovisioningresource.md) and related types.

## AddAzureInfrastructure(IDistributedApplicationBuilder, string, Action<AzureResourceInfrastructure>)

- Name: `AddAzureInfrastructure(IDistributedApplicationBuilder, string, Action<AzureResourceInfrastructure>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureProvisioningResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure/AzureProvisioningResourceExtensions.cs#L27-L30)

Adds an Azure provisioning resource to the application model.

```csharp
public static class AzureProvisioningResourceExtensions
{
    public static IResourceBuilder<AzureProvisioningResource> AddAzureInfrastructure(
        this IDistributedApplicationBuilder builder,
        string name,
        Action<AzureResourceInfrastructure> configureInfrastructure)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IDistributedApplicationBuilder`)
  The distributed application builder.
- `name` (`string`)
  The name of the resource being added.
- `configureInfrastructure` (`Action<AzureResourceInfrastructure>`)
  A callback used to configure the infrastructure resource.

## Returns

`IResourceBuilder<AzureProvisioningResource>` -- A resource builder for the [AzureProvisioningResource](/reference/api/csharp/aspire.hosting.azure/azureprovisioningresource.md) that can be used for further configuration.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## AsKeyVaultSecret(IAzureKeyVaultSecretReference, AzureResourceInfrastructure)

- Name: `AsKeyVaultSecret(IAzureKeyVaultSecretReference, AzureResourceInfrastructure)`
- Modifiers: `extension`
- Returns: `KeyVaultSecret`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure/AzureProvisioningResourceExtensions.cs#L69-L107)

Gets or creates a `KeyVault.KeyVaultSecret` resource in the specified [AzureResourceInfrastructure](/reference/api/csharp/aspire.hosting.azure/azureresourceinfrastructure.md) for the given [IAzureKeyVaultSecretReference](/reference/api/csharp/aspire.hosting.azure/iazurekeyvaultsecretreference.md).

If the referenced Key Vault or secret does not already exist in the infrastructure, they will be created and added. This allows referencing secrets that are provisioned outside of the current deployment.

```csharp
public static class AzureProvisioningResourceExtensions
{
    public static KeyVaultSecret AsKeyVaultSecret(
        this IAzureKeyVaultSecretReference secretReference,
        AzureResourceInfrastructure infrastructure)
    {
        // ...
    }
}
```

## Parameters

- `secretReference` ([IAzureKeyVaultSecretReference](/reference/api/csharp/aspire.hosting.azure/iazurekeyvaultsecretreference.md))
  The [IAzureKeyVaultSecretReference](/reference/api/csharp/aspire.hosting.azure/iazurekeyvaultsecretreference.md) representing the Key Vault secret to reference.
- `infrastructure` ([AzureResourceInfrastructure](/reference/api/csharp/aspire.hosting.azure/azureresourceinfrastructure.md))
  The [AzureResourceInfrastructure](/reference/api/csharp/aspire.hosting.azure/azureresourceinfrastructure.md) in which to locate or add the `KeyVault.KeyVaultSecret`.

## Returns

`KeyVaultSecret` -- The `KeyVault.KeyVaultSecret` instance corresponding to the given secret reference.

## Remarks

This method is not available in polyglot app hosts.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## AsProvisioningParameter(IResourceBuilder<ParameterResource>, AzureResourceInfrastructure, string?)

- Name: `AsProvisioningParameter(IResourceBuilder<ParameterResource>, AzureResourceInfrastructure, string?)`
- Modifiers: `extension`
- Returns: `ProvisioningParameter`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure/AzureProvisioningResourceExtensions.cs#L131-L134)

Creates a new `Provisioning.ProvisioningParameter` in `infrastructure`, or reuses an existing bicep parameter if one with the same name already exists, that corresponds to `parameterResourceBuilder`.

```csharp
public static class AzureProvisioningResourceExtensions
{
    public static ProvisioningParameter AsProvisioningParameter(
        this IResourceBuilder<ParameterResource> parameterResourceBuilder,
        AzureResourceInfrastructure infrastructure,
        string? parameterName = null)
    {
        // ...
    }
}
```

## Parameters

- `parameterResourceBuilder` (`IResourceBuilder<ParameterResource>`)
  The `ApplicationModel.IResourceBuilder`1` that represents a parameter in the `Hosting.ApplicationModel` to get or create a corresponding `Provisioning.ProvisioningParameter`.
- `infrastructure` ([AzureResourceInfrastructure](/reference/api/csharp/aspire.hosting.azure/azureresourceinfrastructure.md))
  The [AzureResourceInfrastructure](/reference/api/csharp/aspire.hosting.azure/azureresourceinfrastructure.md) that contains the `Provisioning.ProvisioningParameter`.
- `parameterName` (`string?`) `optional`
  The name of the parameter to be assigned.

## Returns

`ProvisioningParameter` -- The corresponding `Provisioning.ProvisioningParameter` that was found or newly created.

## Remarks

This method is not available in polyglot app hosts.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## AsProvisioningParameter(IManifestExpressionProvider, AzureResourceInfrastructure, string?, bool?)

- Name: `AsProvisioningParameter(IManifestExpressionProvider, AzureResourceInfrastructure, string?, bool?)`
- Modifiers: `extension`
- Returns: `ProvisioningParameter`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure/AzureProvisioningResourceExtensions.cs#L152-L159)

Creates a new `Provisioning.ProvisioningParameter` in `infrastructure`, or reuses an existing bicep parameter if one with the same name already exists, that corresponds to the given `manifestExpressionProvider`.

```csharp
public static class AzureProvisioningResourceExtensions
{
    public static ProvisioningParameter AsProvisioningParameter(
        this IManifestExpressionProvider manifestExpressionProvider,
        AzureResourceInfrastructure infrastructure,
        string? parameterName = null,
        bool? isSecure = null)
    {
        // ...
    }
}
```

## Parameters

- `manifestExpressionProvider` (`IManifestExpressionProvider`)
  The `ApplicationModel.IManifestExpressionProvider` that represents the value to use for the `Provisioning.ProvisioningParameter`.
- `infrastructure` ([AzureResourceInfrastructure](/reference/api/csharp/aspire.hosting.azure/azureresourceinfrastructure.md))
  The [AzureResourceInfrastructure](/reference/api/csharp/aspire.hosting.azure/azureresourceinfrastructure.md) that contains the `Provisioning.ProvisioningParameter`.
- `parameterName` (`string?`) `optional`
  The name of the parameter to be assigned.
- `isSecure` (`bool?`) `optional`
  Indicates whether the parameter is secure.

## Returns

`ProvisioningParameter` -- The corresponding `Provisioning.ProvisioningParameter` that was found or newly created.

## Remarks

This method is not available in polyglot app hosts.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## AsProvisioningParameter(ParameterResource, AzureResourceInfrastructure, string?)

- Name: `AsProvisioningParameter(ParameterResource, AzureResourceInfrastructure, string?)`
- Modifiers: `extension`
- Returns: `ProvisioningParameter`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure/AzureProvisioningResourceExtensions.cs#L183-L190)

Creates a new `Provisioning.ProvisioningParameter` in `infrastructure`, or reuses an existing bicep parameter if one with the same name already exists, that corresponds to `parameterResource`.

```csharp
public static class AzureProvisioningResourceExtensions
{
    public static ProvisioningParameter AsProvisioningParameter(
        this ParameterResource parameterResource,
        AzureResourceInfrastructure infrastructure,
        string? parameterName = null)
    {
        // ...
    }
}
```

## Parameters

- `parameterResource` (`ParameterResource`)
  The `ApplicationModel.ParameterResource` that represents a parameter in the `Hosting.ApplicationModel` to get or create a corresponding `Provisioning.ProvisioningParameter`.
- `infrastructure` ([AzureResourceInfrastructure](/reference/api/csharp/aspire.hosting.azure/azureresourceinfrastructure.md))
  The [AzureResourceInfrastructure](/reference/api/csharp/aspire.hosting.azure/azureresourceinfrastructure.md) that contains the `Provisioning.ProvisioningParameter`.
- `parameterName` (`string?`) `optional`
  The name of the parameter to be assigned.

## Returns

`ProvisioningParameter` -- The corresponding `Provisioning.ProvisioningParameter` that was found or newly created.

## Remarks

This method is not available in polyglot app hosts.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## AsProvisioningParameter(BicepOutputReference, AzureResourceInfrastructure, string?)

- Name: `AsProvisioningParameter(BicepOutputReference, AzureResourceInfrastructure, string?)`
- Modifiers: `extension`
- Returns: `ProvisioningParameter`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure/AzureProvisioningResourceExtensions.cs#L213-L220)

Creates a new `Provisioning.ProvisioningParameter` in `infrastructure`, or reuses an existing bicep parameter if one with the same name already exists, that corresponds to `outputReference`.

```csharp
public static class AzureProvisioningResourceExtensions
{
    public static ProvisioningParameter AsProvisioningParameter(
        this BicepOutputReference outputReference,
        AzureResourceInfrastructure infrastructure,
        string? parameterName = null)
    {
        // ...
    }
}
```

## Parameters

- `outputReference` ([BicepOutputReference](/reference/api/csharp/aspire.hosting.azure/bicepoutputreference.md))
  The [BicepOutputReference](/reference/api/csharp/aspire.hosting.azure/bicepoutputreference.md) that contains the value to use for the `Provisioning.ProvisioningParameter`.
- `infrastructure` ([AzureResourceInfrastructure](/reference/api/csharp/aspire.hosting.azure/azureresourceinfrastructure.md))
  The [AzureResourceInfrastructure](/reference/api/csharp/aspire.hosting.azure/azureresourceinfrastructure.md) that contains the `Provisioning.ProvisioningParameter`.
- `parameterName` (`string?`) `optional`
  The name of the parameter to be assigned.

## Returns

`ProvisioningParameter` -- The corresponding `Provisioning.ProvisioningParameter` that was found or newly created.

## Remarks

This method is not available in polyglot app hosts.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## AsProvisioningParameter(EndpointReference, AzureResourceInfrastructure, string)

- Name: `AsProvisioningParameter(EndpointReference, AzureResourceInfrastructure, string)`
- Modifiers: `extension`
- Returns: `ProvisioningParameter`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure/AzureProvisioningResourceExtensions.cs#L241-L247)

Creates a new `Provisioning.ProvisioningParameter` in `infrastructure`, or reuses an existing bicep parameter if one with the same name already exists, that corresponds to `endpointReference`.

```csharp
public static class AzureProvisioningResourceExtensions
{
    public static ProvisioningParameter AsProvisioningParameter(
        this EndpointReference endpointReference,
        AzureResourceInfrastructure infrastructure,
        string parameterName)
    {
        // ...
    }
}
```

## Parameters

- `endpointReference` (`EndpointReference`)
  The `ApplicationModel.EndpointReference` to use for the value of the `Provisioning.ProvisioningParameter`.
- `infrastructure` ([AzureResourceInfrastructure](/reference/api/csharp/aspire.hosting.azure/azureresourceinfrastructure.md))
  The [AzureResourceInfrastructure](/reference/api/csharp/aspire.hosting.azure/azureresourceinfrastructure.md) that contains the `Provisioning.ProvisioningParameter`.
- `parameterName` (`string`)
  The name of the parameter to be assigned.

## Returns

`ProvisioningParameter` -- The corresponding `Provisioning.ProvisioningParameter` that was found or newly created.

## Remarks

This method is not available in polyglot app hosts.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## AsProvisioningParameter(ReferenceExpression, AzureResourceInfrastructure, string)

- Name: `AsProvisioningParameter(ReferenceExpression, AzureResourceInfrastructure, string)`
- Modifiers: `extension`
- Returns: `ProvisioningParameter`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure/AzureProvisioningResourceExtensions.cs#L268-L274)

Creates a new `Provisioning.ProvisioningParameter` in `infrastructure`, or reuses an existing bicep parameter if one with the same name already exists, that corresponds to `expression`.

```csharp
public static class AzureProvisioningResourceExtensions
{
    public static ProvisioningParameter AsProvisioningParameter(
        this ReferenceExpression expression,
        AzureResourceInfrastructure infrastructure,
        string parameterName)
    {
        // ...
    }
}
```

## Parameters

- `expression` (`ReferenceExpression`)
  The `ApplicationModel.ReferenceExpression` that represents the value to use for the `Provisioning.ProvisioningParameter`.
- `infrastructure` ([AzureResourceInfrastructure](/reference/api/csharp/aspire.hosting.azure/azureresourceinfrastructure.md))
  The [AzureResourceInfrastructure](/reference/api/csharp/aspire.hosting.azure/azureresourceinfrastructure.md) that contains the `Provisioning.ProvisioningParameter`.
- `parameterName` (`string`)
  The name of the parameter to be assigned.

## Returns

`ProvisioningParameter` -- The corresponding `Provisioning.ProvisioningParameter` that was found or newly created.

## Remarks

This method is not available in polyglot app hosts.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## ConfigureInfrastructure(IResourceBuilder<T>, Action<AzureResourceInfrastructure>)

- Name: `ConfigureInfrastructure(IResourceBuilder<T>, Action<AzureResourceInfrastructure>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<T>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure/AzureProvisioningResourceExtensions.cs#L45-L49)

Configures the Azure provisioning resource `Provisioning.Infrastructure`.

```csharp
public static class AzureProvisioningResourceExtensions
{
    public static IResourceBuilder<T> ConfigureInfrastructure<T>(
        this IResourceBuilder<T> builder,
        Action<AzureResourceInfrastructure> configure)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<T>`)
  The resource builder.
- `configure` (`Action<AzureResourceInfrastructure>`)
  The configuration callback.

## Returns

`IResourceBuilder<T>` -- The resource builder.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.
