# IResourceWithEnvironment

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

## Definition

```typescript
interface IResourceWithEnvironment {
  withCertificateTrustScope(scope: CertificateTrustScope): IResourceWithEnvironment;
  withDeveloperCertificateTrust(trust: boolean): IResourceWithEnvironment;
  withEnvironment(
      name: string,
      value: IResourceWithConnectionString): IResourceWithEnvironment;
  withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise<void>): IResourceWithEnvironment;
  withEnvironmentConnectionString(
      envVarName: string,
      resource: IResourceWithConnectionString): IResourceWithEnvironment;
  withEnvironmentEndpoint(
      name: string,
      endpointReference: EndpointReference): IResourceWithEnvironment;
  withEnvironmentParameter(
      name: string,
      parameter: ParameterResource): IResourceWithEnvironment;
  withHttpsDeveloperCertificate(password?: ParameterResource): IResourceWithEnvironment;
  withOtlpExporter(): IResourceWithEnvironment;
  withOtlpExporterProtocol(protocol: OtlpProtocol): IResourceWithEnvironment;
  withoutHttpsCertificate(): IResourceWithEnvironment;
  withReference(
      source: IResource,
      connectionName?: string,
      optional?: boolean,
      name?: string): IResourceWithEnvironment;
  withReferenceEndpoint(endpointReference: EndpointReference): IResourceWithEnvironment;
  withReferenceExternalService(externalService: ExternalServiceResource): IResourceWithEnvironment;
  withReferenceUri(
      name: string,
      uri: uri): 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` -- Configures developer certificate trust
    ```typescript
  withDeveloperCertificateTrust(trust: boolean): IResourceWithEnvironment
  ```
- [withEnvironment](/reference/api/typescript/aspire.hosting/iresourcewithenvironment/withenvironment.md) -- `method` -- Sets an environment variable on the resource
    ```typescript
  withEnvironment(name: string, value: IResourceWithConnectionString): IResourceWithEnvironment
  ```
- [withEnvironmentCallback](/reference/api/typescript/aspire.hosting/iresourcewithenvironment/withenvironmentcallback.md) -- `method` -- Sets environment variables via callback
    ```typescript
  withEnvironmentCallback(callback: (arg: EnvironmentCallbackContext) => Promise<void>): IResourceWithEnvironment
  ```
- [withEnvironmentConnectionString](/reference/api/typescript/aspire.hosting/iresourcewithenvironment/withenvironmentconnectionstring.md) -- `method` -- Sets an environment variable from a connection string resource
    ```typescript
  withEnvironmentConnectionString(envVarName: string, resource: IResourceWithConnectionString): IResourceWithEnvironment
  ```
- [withEnvironmentEndpoint](/reference/api/typescript/aspire.hosting/iresourcewithenvironment/withenvironmentendpoint.md) -- `method` -- Sets an environment variable from an endpoint reference
    ```typescript
  withEnvironmentEndpoint(name: string, endpointReference: EndpointReference): IResourceWithEnvironment
  ```
- [withEnvironmentParameter](/reference/api/typescript/aspire.hosting/iresourcewithenvironment/withenvironmentparameter.md) -- `method` -- Sets an environment variable from a parameter resource
    ```typescript
  withEnvironmentParameter(name: string, parameter: ParameterResource): IResourceWithEnvironment
  ```
- [withHttpsDeveloperCertificate](/reference/api/typescript/aspire.hosting/iresourcewithenvironment/withhttpsdevelopercertificate.md) -- `method` -- Configures HTTPS with a developer certificate
    ```typescript
  withHttpsDeveloperCertificate(password?: ParameterResource): IResourceWithEnvironment
  ```
- [withOtlpExporter](/reference/api/typescript/aspire.hosting/iresourcewithenvironment/withotlpexporter.md) -- `method` -- Configures OTLP telemetry export
    ```typescript
  withOtlpExporter(): IResourceWithEnvironment
  ```
- [withOtlpExporterProtocol](/reference/api/typescript/aspire.hosting/iresourcewithenvironment/withotlpexporterprotocol.md) -- `method` -- Configures OTLP telemetry export with specific protocol
    ```typescript
  withOtlpExporterProtocol(protocol: OtlpProtocol): IResourceWithEnvironment
  ```
- [withoutHttpsCertificate](/reference/api/typescript/aspire.hosting/iresourcewithenvironment/withouthttpscertificate.md) -- `method` -- Removes HTTPS certificate configuration
    ```typescript
  withoutHttpsCertificate(): IResourceWithEnvironment
  ```
- [withReference](/reference/api/typescript/aspire.hosting/iresourcewithenvironment/withreference.md) -- `method` -- Adds a reference to another resource
    ```typescript
  withReference(source: IResource, connectionName?: string, optional?: boolean, name?: string): IResourceWithEnvironment
  ```
- [withReferenceEndpoint](/reference/api/typescript/aspire.hosting/iresourcewithenvironment/withreferenceendpoint.md) -- `method` -- Adds a reference to an endpoint
    ```typescript
  withReferenceEndpoint(endpointReference: EndpointReference): IResourceWithEnvironment
  ```
- [withReferenceExternalService](/reference/api/typescript/aspire.hosting/iresourcewithenvironment/withreferenceexternalservice.md) -- `method` -- Adds a reference to an external service
    ```typescript
  withReferenceExternalService(externalService: ExternalServiceResource): IResourceWithEnvironment
  ```
- [withReferenceUri](/reference/api/typescript/aspire.hosting/iresourcewithenvironment/withreferenceuri.md) -- `method` -- Adds a reference to a URI
    ```typescript
  withReferenceUri(name: string, uri: uri): IResourceWithEnvironment
  ```
