Skip to content
Docs Try Aspire

Service Methods

Class Methods 4 members
Represents a Docker Compose service definition.
Adds a configuration reference to the service's list of configurations. This method allows you to include external configuration resources that the service can utilize at runtime.
public sealed class Service
{
public Service AddConfig(
ConfigReference config)
{
// ...
}
}
config ConfigReference The config reference to add
Service The updated Service instance with the added environmental variable.
Adds an environmental variable to the service's environment dictionary. If the specified value is null, it assigns an empty string as the value.
public sealed class Service
{
public Service AddEnvironmentalVariable(
string key,
string? value)
{
// ...
}
}
key string The key for the environmental variable.
value string? The value of the environmental variable. If null, an empty string will be used.
Service The updated Service instance with the added environmental variable.
Adds a volume to the service's list of volumes. If the volumes collection is null, it initializes a new collection before adding the volume.
public sealed class Service
{
public Service AddVolume(
Volume volume)
{
// ...
}
}
volume Volume The volume to be added to the service.
Service The updated Service instance with the added volume.
Adds multiple volumes to the service's list of volumes. If the volumes collection is empty, the provided volumes will be appended to the existing collection.
public sealed class Service
{
public Service AddVolumes(
IEnumerable<Volume> volumes)
{
// ...
}
}
volumes IEnumerable<Volume> A collection of volumes to be added to the service.
Service The updated Service instance with the added volumes.