# AzureBicepResourceExtensions Methods

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

Extension methods for adding Azure Bicep resources to the application model.

## AddBicepTemplate(IDistributedApplicationBuilder, string, string)

- Name: `AddBicepTemplate(IDistributedApplicationBuilder, string, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureBicepResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure/AzureBicepResourceExtensions.cs#L27-L31)

Adds an Azure Bicep resource to the application model.

```csharp
public static class AzureBicepResourceExtensions
{
    public static IResourceBuilder<AzureBicepResource> AddBicepTemplate(
        this IDistributedApplicationBuilder builder,
        string name,
        string bicepFile)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IDistributedApplicationBuilder`)
  The `Hosting.IDistributedApplicationBuilder`.
- `name` (`string`)
  The name of the resource. This name will be used as the deployment name.
- `bicepFile` (`string`)
  The path to the bicep file on disk. This path is relative to the apphost's project directory.

## Returns

`IResourceBuilder<AzureBicepResource>` -- An `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## AddBicepTemplateString(IDistributedApplicationBuilder, string, string)

- Name: `AddBicepTemplateString(IDistributedApplicationBuilder, string, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureBicepResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure/AzureBicepResourceExtensions.cs#L45-L48)

Adds an Azure Bicep resource to the application model.

```csharp
public static class AzureBicepResourceExtensions
{
    public static IResourceBuilder<AzureBicepResource> AddBicepTemplateString(
        this IDistributedApplicationBuilder builder,
        string name,
        string bicepContent)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IDistributedApplicationBuilder`)
  The `Hosting.IDistributedApplicationBuilder`.
- `name` (`string`)
  The name of the resource. This name will be used as the deployment name.
- `bicepContent` (`string`)
  A string that represents a snippet of bicep.

## Returns

`IResourceBuilder<AzureBicepResource>` -- An `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## GetOutput(IResourceBuilder<AzureBicepResource>, string)

- Name: `GetOutput(IResourceBuilder<AzureBicepResource>, string)`
- Modifiers: `extension`
- Returns: [BicepOutputReference](/reference/api/csharp/aspire.hosting.azure/bicepoutputreference.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure/AzureBicepResourceExtensions.cs#L60)

Gets a reference to an output from a bicep template.

```csharp
public static class AzureBicepResourceExtensions
{
    public static BicepOutputReference GetOutput(
        this IResourceBuilder<AzureBicepResource> builder,
        string name)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<AzureBicepResource>`)
  The resource builder.
- `name` (`string`)
  Name of the output.

## Returns

[BicepOutputReference](/reference/api/csharp/aspire.hosting.azure/bicepoutputreference.md) -- A [BicepOutputReference](/reference/api/csharp/aspire.hosting.azure/bicepoutputreference.md) that represents the output.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## GetSecretOutput(IResourceBuilder<AzureBicepResource>, string)

> **Obsolete:** GetSecretOutput is obsolete. Use IAzureKeyVaultResource.GetSecret instead.

- Name: `GetSecretOutput(IResourceBuilder<AzureBicepResource>, string)`
- Modifiers: `extension`
- Returns: [BicepSecretOutputReference](/reference/api/csharp/aspire.hosting.azure/bicepsecretoutputreference.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure/AzureBicepResourceExtensions.cs#L72)

Gets a reference to a secret output from a bicep template. This is an output that is written to a keyvault using the "keyVaultName" convention.

```csharp
public static class AzureBicepResourceExtensions
{
    public static BicepSecretOutputReference GetSecretOutput(
        this IResourceBuilder<AzureBicepResource> builder,
        string name)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<AzureBicepResource>`)
  The resource builder.
- `name` (`string`)
  The name of the secret output.

## Returns

[BicepSecretOutputReference](/reference/api/csharp/aspire.hosting.azure/bicepsecretoutputreference.md) -- A [BicepSecretOutputReference](/reference/api/csharp/aspire.hosting.azure/bicepsecretoutputreference.md) that represents the output.

## WithEnvironment(IResourceBuilder<T>, string, BicepOutputReference)

- Name: `WithEnvironment(IResourceBuilder<T>, string, BicepOutputReference)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<T>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure/AzureBicepResourceExtensions.cs)

Adds an environment variable to the resource with the value of the output from the bicep template.

```csharp
public static class AzureBicepResourceExtensions
{
    public static IResourceBuilder<T> WithEnvironment<T>(
        this IResourceBuilder<T> builder,
        string name,
        BicepOutputReference bicepOutputReference)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<T>`)
  The resource builder.
- `name` (`string`)
  The name of the environment variable.
- `bicepOutputReference` ([BicepOutputReference](/reference/api/csharp/aspire.hosting.azure/bicepoutputreference.md))
  The reference to the bicep output.

## Returns

`IResourceBuilder<T>` -- An `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## WithEnvironment(IResourceBuilder<T>, string, BicepSecretOutputReference)

> **Obsolete:** BicepSecretOutputReference is no longer supported. Use WithEnvironment(IAzureKeyVaultSecretReference) instead.

- Name: `WithEnvironment(IResourceBuilder<T>, string, BicepSecretOutputReference)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<T>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure/AzureBicepResourceExtensions.cs)

Adds an environment variable to the resource with the value of the secret output from the bicep template.

```csharp
public static class AzureBicepResourceExtensions
{
    public static IResourceBuilder<T> WithEnvironment<T>(
        this IResourceBuilder<T> builder,
        string name,
        BicepSecretOutputReference bicepOutputReference)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<T>`)
  The resource builder.
- `name` (`string`)
  The name of the environment variable.
- `bicepOutputReference` ([BicepSecretOutputReference](/reference/api/csharp/aspire.hosting.azure/bicepsecretoutputreference.md))
  The reference to the bicep output.

## Returns

`IResourceBuilder<T>` -- An `ApplicationModel.IResourceBuilder`1`.

## WithEnvironment(IResourceBuilder<T>, string, IAzureKeyVaultSecretReference)

- Name: `WithEnvironment(IResourceBuilder<T>, string, IAzureKeyVaultSecretReference)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<T>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure/AzureBicepResourceExtensions.cs#L120)

Adds an environment variable to the resource with the value of the key vault secret.

```csharp
public static class AzureBicepResourceExtensions
{
    public static IResourceBuilder<T> WithEnvironment<T>(
        this IResourceBuilder<T> builder,
        string name,
        IAzureKeyVaultSecretReference secretReference)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<T>`)
  The resource builder.
- `name` (`string`)
  The name of the environment variable.
- `secretReference` ([IAzureKeyVaultSecretReference](/reference/api/csharp/aspire.hosting.azure/iazurekeyvaultsecretreference.md))
  The reference to the key vault secret.

## Returns

`IResourceBuilder<T>` -- An `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## WithParameter(IResourceBuilder<T>, string)

- Name: `WithParameter(IResourceBuilder<T>, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<T>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure/AzureBicepResourceExtensions.cs#L134-L136)

Adds a parameter to the bicep template.

```csharp
public static class AzureBicepResourceExtensions
{
    public static IResourceBuilder<T> WithParameter<T>(
        this IResourceBuilder<T> builder,
        string name)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<T>`)
  The resource builder.
- `name` (`string`)
  The name of the input.

## Returns

`IResourceBuilder<T>` -- An `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## WithParameter(IResourceBuilder<T>, string, string)

- Name: `WithParameter(IResourceBuilder<T>, string, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<T>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure/AzureBicepResourceExtensions.cs)

Adds a parameter to the bicep template.

```csharp
public static class AzureBicepResourceExtensions
{
    public static IResourceBuilder<T> WithParameter<T>(
        this IResourceBuilder<T> builder,
        string name,
        string value)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<T>`)
  The resource builder.
- `name` (`string`)
  The name of the input.
- `value` (`string`)
  The value of the parameter.

## Returns

`IResourceBuilder<T>` -- An `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## WithParameter(IResourceBuilder<T>, string, IEnumerable<string>)

- Name: `WithParameter(IResourceBuilder<T>, string, IEnumerable<string>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<T>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure/AzureBicepResourceExtensions.cs)

Adds a parameter to the bicep template.

```csharp
public static class AzureBicepResourceExtensions
{
    public static IResourceBuilder<T> WithParameter<T>(
        this IResourceBuilder<T> builder,
        string name,
        IEnumerable<string> value)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<T>`)
  The resource builder.
- `name` (`string`)
  The name of the input.
- `value` (`IEnumerable<string>`)
  The value of the parameter.

## Returns

`IResourceBuilder<T>` -- An `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## WithParameter(IResourceBuilder<T>, string, JsonNode)

- Name: `WithParameter(IResourceBuilder<T>, string, JsonNode)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<T>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure/AzureBicepResourceExtensions.cs)

Adds a parameter to the bicep template.

```csharp
public static class AzureBicepResourceExtensions
{
    public static IResourceBuilder<T> WithParameter<T>(
        this IResourceBuilder<T> builder,
        string name,
        JsonNode value)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<T>`)
  The resource builder.
- `name` (`string`)
  The name of the input.
- `value` (`JsonNode`)
  The value of the parameter.

## Returns

`IResourceBuilder<T>` -- An `ApplicationModel.IResourceBuilder`1`.

## Remarks

This method is not available in polyglot app hosts.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## WithParameter(IResourceBuilder<T>, string, Func<object?>)

- Name: `WithParameter(IResourceBuilder<T>, string, Func<object?>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<T>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure/AzureBicepResourceExtensions.cs#L238-L240)

Adds a parameter to the bicep template.

```csharp
public static class AzureBicepResourceExtensions
{
    public static IResourceBuilder<T> WithParameter<T>(
        this IResourceBuilder<T> builder,
        string name,
        Func<object?> valueCallback)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<T>`)
  The resource builder.
- `name` (`string`)
  The name of the input.
- `valueCallback` (`Func<object?>`)
  The value of the parameter.

## Returns

`IResourceBuilder<T>` -- An `ApplicationModel.IResourceBuilder`1`.

## Remarks

This method is not available in polyglot app hosts.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## WithParameter(IResourceBuilder<T>, string, IResourceBuilder<ParameterResource>)

- Name: `WithParameter(IResourceBuilder<T>, string, IResourceBuilder<ParameterResource>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<T>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure/AzureBicepResourceExtensions.cs)

Adds a parameter to the bicep template.

```csharp
public static class AzureBicepResourceExtensions
{
    public static IResourceBuilder<T> WithParameter<T>(
        this IResourceBuilder<T> builder,
        string name,
        IResourceBuilder<ParameterResource> value)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<T>`)
  The resource builder.
- `name` (`string`)
  The name of the input.
- `value` (`IResourceBuilder<ParameterResource>`)
  The value of the parameter.

## Returns

`IResourceBuilder<T>` -- An `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## WithParameter(IResourceBuilder<T>, string, ParameterResource)

- Name: `WithParameter(IResourceBuilder<T>, string, ParameterResource)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<T>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure/AzureBicepResourceExtensions.cs)

Adds a parameter to the bicep template.

```csharp
public static class AzureBicepResourceExtensions
{
    public static IResourceBuilder<T> WithParameter<T>(
        this IResourceBuilder<T> builder,
        string name,
        ParameterResource value)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<T>`)
  The resource builder.
- `name` (`string`)
  The name of the input.
- `value` (`ParameterResource`)
  The value of the parameter.

## Returns

`IResourceBuilder<T>` -- An `ApplicationModel.IResourceBuilder`1`.

## Remarks

This overload is not available in polyglot app hosts. Use the [AzureBicepResourceExtensions.WithParameter(IResourceBuilder<T>, string)](/reference/api/csharp/aspire.hosting.azure/azurebicepresourceextensions/methods.md#withparameter-iresourcebuilder-t-string) overload instead.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## WithParameter(IResourceBuilder<T>, string, IResourceBuilder<IResourceWithConnectionString>)

- Name: `WithParameter(IResourceBuilder<T>, string, IResourceBuilder<IResourceWithConnectionString>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<T>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure/AzureBicepResourceExtensions.cs)

Adds a parameter to the bicep template.

```csharp
public static class AzureBicepResourceExtensions
{
    public static IResourceBuilder<T> WithParameter<T>(
        this IResourceBuilder<T> builder,
        string name,
        IResourceBuilder<IResourceWithConnectionString> value)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<T>`)
  The resource builder.
- `name` (`string`)
  The name of the input.
- `value` (`IResourceBuilder<IResourceWithConnectionString>`)
  The value of the parameter.

## Returns

`IResourceBuilder<T>` -- An `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## WithParameter(IResourceBuilder<T>, string, BicepOutputReference)

- Name: `WithParameter(IResourceBuilder<T>, string, BicepOutputReference)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<T>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure/AzureBicepResourceExtensions.cs)

Adds a parameter to the bicep template.

```csharp
public static class AzureBicepResourceExtensions
{
    public static IResourceBuilder<T> WithParameter<T>(
        this IResourceBuilder<T> builder,
        string name,
        BicepOutputReference value)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<T>`)
  The resource builder.
- `name` (`string`)
  The name of the input.
- `value` ([BicepOutputReference](/reference/api/csharp/aspire.hosting.azure/bicepoutputreference.md))
  The value of the parameter.

## Returns

`IResourceBuilder<T>` -- An `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## WithParameter(IResourceBuilder<T>, string, ReferenceExpression)

- Name: `WithParameter(IResourceBuilder<T>, string, ReferenceExpression)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<T>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure/AzureBicepResourceExtensions.cs)

Adds a parameter to the bicep template.

```csharp
public static class AzureBicepResourceExtensions
{
    public static IResourceBuilder<T> WithParameter<T>(
        this IResourceBuilder<T> builder,
        string name,
        ReferenceExpression value)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<T>`)
  The resource builder.
- `name` (`string`)
  The name of the input.
- `value` (`ReferenceExpression`)
  The value of the parameter.

## Returns

`IResourceBuilder<T>` -- An `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## WithParameter(IResourceBuilder<T>, string, EndpointReference)

- Name: `WithParameter(IResourceBuilder<T>, string, EndpointReference)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<T>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure/AzureBicepResourceExtensions.cs)

Adds a parameter to the bicep template.

```csharp
public static class AzureBicepResourceExtensions
{
    public static IResourceBuilder<T> WithParameter<T>(
        this IResourceBuilder<T> builder,
        string name,
        EndpointReference value)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<T>`)
  The resource builder.
- `name` (`string`)
  The name of the input.
- `value` (`EndpointReference`)
  The value of the parameter.

## Returns

`IResourceBuilder<T>` -- An `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.
