-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dotnet isolated docker: docker run -e PORT=80 messes with the function host command line arguments #524
Comments
I have a workaround: remove the configuration sources, and re-add them in the proper order, but something should be done to avoid having multiple meanings for the same option name. public static void Main(string[] args)
{
// Linux: remove the first argument if it's the executable name
var newArgs = args;
if (args.Length > 0 && args[0] == typeof(Program).Assembly.Location)
{
newArgs = new string[args.Length - 1];
Array.Copy(args, 1, newArgs, 0, args.Length - 1);
}
var host = Host
.CreateDefaultBuilder()
.ConfigureFunctionsWorkerDefaults()
.ConfigureAppConfiguration(builder =>
{
// reorder the configuration source, so that the command line arguments take precedences over the env variables
var sources = builder.Sources;
var toRemoves = sources
.Where(s => (s is EnvironmentVariablesConfigurationSource env && env.Prefix == null)
|| (s is CommandLineConfigurationSource)
).ToList();
foreach(var toRemove in toRemoves)
{
sources.Remove(toRemove);
}
builder.AddEnvironmentVariables();
builder.AddCommandLine(newArgs);
})
.Build();
host.Run();
} |
Interestingly, the
When
|
Yeah, this is a bug. We meant for the command line arguments to be applied last, as you have done in your workaround. Even though this is technically a breaking change, we agree that it will have minimal impact and it's worth it for us to swap this to make it correct. |
Sorry for the stupid question but how do you set the |
You can't directly: for my tests, I started with a brand new Azure function created via the Azure portal, and then I changed the docker image to a custom one. I don't know how to switch it back to the |
I just applied your code to change the command line arguments and this has fixed my issue. Thank you! I am talking to Microsoft Technical support and linked them to this issue so hopefully someone will pick it up and get it fixed |
@fabiocav Is there any change required on our end to get this update? Or is it a case of removing the workaround and see if it now works? |
When a Linux function app uses a custom docker image, the docker container is ran with the
-e PORT=80
option.That creates an issue with the gRPC configuration, that ALSO uses the Port variable, and which is passed as a command line parameter.
We therefore have two conflicting Port options:
That's an issue, because the environment variable value takes precedence over the command line value, and therefore the gRPC connection tries to connect to port 80 instead of the actual gRPC port.
The text was updated successfully, but these errors were encountered: