# AzureEnvironmentResourceExtensions Methods

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

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

## AddAzureEnvironment(IDistributedApplicationBuilder)

> **Experimental:** ASPIREAZURE001 - [Learn more](/diagnostics/aspireazure001/)

- Name: `AddAzureEnvironment(IDistributedApplicationBuilder)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureEnvironmentResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure/AzureEnvironmentResourceExtensions.cs#L24-L51)

Adds an Azure environment resource to the application model.

```csharp
public static class AzureEnvironmentResourceExtensions
{
    public static IResourceBuilder<AzureEnvironmentResource> AddAzureEnvironment(
        this IDistributedApplicationBuilder builder)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IDistributedApplicationBuilder`)
  The `Hosting.IDistributedApplicationBuilder`.

## Returns

`IResourceBuilder<AzureEnvironmentResource>` -- The `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithLocation(IResourceBuilder<AzureEnvironmentResource>, IResourceBuilder<ParameterResource>)

> **Experimental:** ASPIREAZURE001 - [Learn more](/diagnostics/aspireazure001/)

- Name: `WithLocation(IResourceBuilder<AzureEnvironmentResource>, IResourceBuilder<ParameterResource>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureEnvironmentResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure/AzureEnvironmentResourceExtensions.cs#L71-L76)

Sets the location of the Azure environment resource.

```csharp
public static class AzureEnvironmentResourceExtensions
{
    public static IResourceBuilder<AzureEnvironmentResource> WithLocation(
        this IResourceBuilder<AzureEnvironmentResource> builder,
        IResourceBuilder<ParameterResource> location)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<AzureEnvironmentResource>`)
  The `ApplicationModel.IResourceBuilder`1`.
- `location` (`IResourceBuilder<ParameterResource>`)
  The Azure location.

## Returns

`IResourceBuilder<AzureEnvironmentResource>` -- The `ApplicationModel.IResourceBuilder`1`.

## Remarks

This method is used to set the location of the Azure environment resource. The location is used to determine where the resources will be deployed.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithResourceGroup(IResourceBuilder<AzureEnvironmentResource>, IResourceBuilder<ParameterResource>)

> **Experimental:** ASPIREAZURE001 - [Learn more](/diagnostics/aspireazure001/)

- Name: `WithResourceGroup(IResourceBuilder<AzureEnvironmentResource>, IResourceBuilder<ParameterResource>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureEnvironmentResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure/AzureEnvironmentResourceExtensions.cs#L96-L101)

Sets the resource group name of the Azure environment resource.

```csharp
public static class AzureEnvironmentResourceExtensions
{
    public static IResourceBuilder<AzureEnvironmentResource> WithResourceGroup(
        this IResourceBuilder<AzureEnvironmentResource> builder,
        IResourceBuilder<ParameterResource> resourceGroup)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<AzureEnvironmentResource>`)
  The `ApplicationModel.IResourceBuilder`1`.
- `resourceGroup` (`IResourceBuilder<ParameterResource>`)
  The Azure resource group name.

## Returns

`IResourceBuilder<AzureEnvironmentResource>` -- The `ApplicationModel.IResourceBuilder`1`.

## Remarks

This method is used to set the resource group name of the Azure environment resource. The resource group name is used to determine where the resources will be deployed.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.
