Setting container environment variable with SQL Server host #4255
Answered
by
davidfowl
paulomorgado
asked this question in
Q&A
-
I need to set environment variables on a container with the SQL Server host and port. I can get the port with: ctx.EnvironmentVariables[$"PORT_{connectionName}"] = sqlServerServerResource.PrimaryEndpoint.Property(EndpointProperty.Port); But: ctx.EnvironmentVariables[$"SERVER_{connectionName}"] = sqlServerServerResource.PrimaryEndpoint.Property(EndpointProperty.IPV4Host); will always get me I have to resort to: ctx.EnvironmentVariables[$"SERVER_{connectionName}"] = sqlServerServerResource.PrimaryEndpoint.ContainerHost; I guess that's because Is there a workaround to this? |
Beta Was this translation helpful? Give feedback.
Answered by
davidfowl
May 23, 2024
Replies: 2 comments
-
This works: ctx.EnvironmentVariables[$"SERVER_{connectionName}"] = new HostUrl(sqlServerServerResource.PrimaryEndpoint.Host); But it feels like it's missing a /// <summary>
/// Represents a host reference on the host machine. When referenced in a container resource, localhost will be
/// replaced with the configured container host name.
/// </summary>
public record HostReference(IValueProvider HostReference) : IValueProvider, IManifestExpressionProvider
{
// Goes into the manifest as a value, not an expression
string IManifestExpressionProvider.ValueExpression => "host";
// Returns the url
ValueTask<string?> IValueProvider.GetValueAsync(System.Threading.CancellationToken cancellationToken)
=> HostReference.GetValueAsync(cancellationToken);
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
See #3735. This is a gap. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
paulomorgado
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See #3735. This is a gap.