https://pulumi.com logo
#dotnet
Title
# dotnet
g

glamorous-waitress-51149

08/24/2022, 10:58 AM
this is similar to my issue. is there a way to add to a container app’s env vars the url of the container app that is being created? You can get the url like so
Url      = Output.Format($"https://{app.Configuration.Apply(x => x!.Ingress).Apply(x => x!.Fqdn)}");
but obviously it’s cyclic dependency issue, you’re trying to add the url to the envvars but the url doesn’t exist yet
e

echoing-dinner-19531

08/24/2022, 12:13 PM
Circular dependencies aren't really supported at the moment, there's some tricks to work around it explained in https://www.pulumi.com/blog/exploring-circular-dependencies/ but all a bit odd
🙌 1
👍 1
g

glamorous-waitress-51149

08/24/2022, 12:14 PM
Thanks
f

fast-vr-6049

08/25/2022, 5:35 PM
A container apps specific workaround could be using a custom DNS address + SSL certificate. That way, you can set the DNS address as a pulumi config value, provision the custom address, and pass the already-known custom address into the container app's env vars
g

glamorous-waitress-51149

08/25/2022, 5:39 PM
i found i could do this due , the envvar coming from MS
Copy code
public static Uri GetContainerAppAddress(string name, bool secure = true, int? port = null) {
        if (IsNullOrWhiteSpace(name))
            throw new ArgumentException("Container App name cannot be null or whitespace.", nameof(name));

        var suffix = Environment.GetEnvironmentVariable("CONTAINER_APP_ENV_DNS_SUFFIX");
        var host   = $"{name}{(suffix is not null ? $".{suffix}" : "")}";
        var url    = $"{(secure ? "https" : "http")}://{host}{(port is not null ? $":{port}" : "")}";
        
        return new Uri(url);
    }
f

fast-vr-6049

08/25/2022, 5:43 PM
Good call!