# IResourceWithEnvironment

- Module: [Aspire.Hosting](/reference/api/typescript/aspire.hosting.md)
- Version: `13.4.0`
- Kind: `interface`
- Source: [GitHub](https://github.com/microsoft/aspire)

Represents a resource that is associated with an environment.

## Definition

```typescript
interface IResourceWithEnvironment {
  withCertificateTrustScope(scope: CertificateTrustScope): IResourceWithEnvironment;
  withDeveloperCertificateTrust(trust: boolean): IResourceWithEnvironment;
  withEnvironment(
      name: string,
      value: IExpressionValue): IResourceWithEnvironment;
  withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise<void>): IResourceWithEnvironment;
  withHttpsDeveloperCertificate(password?: ParameterResource): IResourceWithEnvironment;
  withOtlpExporter(protocol?: OtlpProtocol): IResourceWithEnvironment;
  withoutHttpsCertificate(): IResourceWithEnvironment;
  withReference(
      source: EndpointReference|string|uri,
      connectionName?: string,
      optional?: boolean,
      name?: string): IResourceWithEnvironment;
  withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): IResourceWithEnvironment;
}
```

## Methods

- [withCertificateTrustScope](/reference/api/typescript/aspire.hosting/iresourcewithenvironment/withcertificatetrustscope.md) -- `method` -- Sets the certificate trust scope
    ```typescript
  withCertificateTrustScope(scope: CertificateTrustScope): IResourceWithEnvironment
  ```
- [withDeveloperCertificateTrust](/reference/api/typescript/aspire.hosting/iresourcewithenvironment/withdevelopercertificatetrust.md) -- `method` -- Indicates whether developer certificates should be treated as trusted certificate authorities for the resource at run time. Currently this indicates trust for the ASP.NET Core developer certificate. The developer certificate will only be trusted when running in local development scenarios; in publish mode resources will use their default certificate trust.
    ```typescript
  withDeveloperCertificateTrust(trust: boolean): IResourceWithEnvironment
  ```
- [withEnvironment](/reference/api/typescript/aspire.hosting/iresourcewithenvironment/withenvironment.md) -- `method` -- Sets an environment variable
    ```typescript
  withEnvironment(name: string, value: IExpressionValue): IResourceWithEnvironment
  ```
- [withEnvironmentCallback](/reference/api/typescript/aspire.hosting/iresourcewithenvironment/withenvironmentcallback.md) -- `method` -- Allows for the population of environment variables on a resource.
    ```typescript
  withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise<void>): IResourceWithEnvironment
  ```
- [withHttpsDeveloperCertificate](/reference/api/typescript/aspire.hosting/iresourcewithenvironment/withhttpsdevelopercertificate.md) -- `method` -- Indicates that a resource should use the developer certificate key pair for HTTPS endpoints at run time. Currently this indicates use of the ASP.NET Core developer certificate. The developer certificate will only be used when running in local development scenarios; in publish mode resources will use their default certificate configuration.
    ```typescript
  withHttpsDeveloperCertificate(password?: ParameterResource): IResourceWithEnvironment
  ```
- [withOtlpExporter](/reference/api/typescript/aspire.hosting/iresourcewithenvironment/withotlpexporter.md) -- `method` -- Configures OTLP telemetry export
    ```typescript
  withOtlpExporter(protocol?: OtlpProtocol): IResourceWithEnvironment
  ```
- [withoutHttpsCertificate](/reference/api/typescript/aspire.hosting/iresourcewithenvironment/withouthttpscertificate.md) -- `method` -- Disable HTTPS/TLS server certificate configuration for the resource. No HTTPS/TLS termination configuration will be applied.
    ```typescript
  withoutHttpsCertificate(): IResourceWithEnvironment
  ```
- [withReference](/reference/api/typescript/aspire.hosting/iresourcewithenvironment/withreference.md) -- `method` -- Adds a reference to another resource
    ```typescript
  withReference(source: EndpointReference|string|uri, connectionName?: string, optional?: boolean, name?: string): IResourceWithEnvironment
  ```
- [withReferenceEnvironment](/reference/api/typescript/aspire.hosting/iresourcewithenvironment/withreferenceenvironment.md) -- `method` -- Configures how information is injected into environment variables when the resource references other resources.
    ```typescript
  withReferenceEnvironment(options: ReferenceEnvironmentInjectionOptions): IResourceWithEnvironment
  ```
