2525using Microsoft . Azure . WebJobs . Host ;
2626using Microsoft . Azure . WebJobs . Host . Config ;
2727using Microsoft . Azure . WebJobs . Extensions . Http ;
28+ using Azure . Functions . Cli . Interfaces ;
2829
2930namespace Azure . Functions . Cli . Actions . HostActions
3031{
@@ -35,6 +36,7 @@ internal class StartHostAction : BaseAction, IDisposable
3536 const int DefaultPort = 7071 ;
3637 const TraceLevel DefaultDebugLevel = TraceLevel . Info ;
3738 const int DefaultTimeout = 20 ;
39+ private readonly ISecretsManager _secretsManager ;
3840
3941 public int Port { get ; set ; }
4042
@@ -50,12 +52,19 @@ internal class StartHostAction : BaseAction, IDisposable
5052
5153 public DebuggerType Debugger { get ; set ; }
5254
55+ public StartHostAction ( ISecretsManager secretsManager )
56+ {
57+ this . _secretsManager = secretsManager ;
58+ }
59+
5360 public override ICommandLineParserResult ParseArgs ( string [ ] args )
5461 {
62+ var hostSettings = _secretsManager . GetHostStartSettings ( ) ;
63+
5564 Parser
5665 . Setup < int > ( 'p' , "port" )
5766 . WithDescription ( $ "Local port to listen on. Default: { DefaultPort } ")
58- . SetDefault ( DefaultPort )
67+ . SetDefault ( hostSettings . LocalHttpPort == default ( int ) ? DefaultPort : hostSettings . LocalHttpPort )
5968 . Callback ( p => Port = p ) ;
6069
6170 Parser
@@ -73,7 +82,7 @@ public override ICommandLineParserResult ParseArgs(string[] args)
7382 Parser
7483 . Setup < string > ( "cors" )
7584 . WithDescription ( $ "A comma separated list of CORS origins with no spaces. Example: https://functions.azure.com,https://functions-staging.azure.com")
76- . SetDefault ( string . Empty )
85+ . SetDefault ( hostSettings . Cors ?? string . Empty )
7786 . Callback ( c => CorsOrigins = c ) ;
7887
7988 Parser
0 commit comments