Both HTTP and HTTPS endpoints on Service Fabric Asp.Net Core stateless Service
<p>I have a Service Fabric Stateless Asp.Net Core service.</p>

<p>The service works with an HTTP endpoint.
<strong>I need to support an HTTPS endpoint along with the HTTP</strong></p>

<p>My steps so far:</p>

<ol>
<li>Added the certificate to Azure KeyVault</li>
<li><p>Updated ApplicationManifest.xml with:</p>

<pre><code>&lt;Policies&gt;
  &lt;EndpointBindingPolicy EndpointRef="ServiceEndpointHttps" CertificateRef="Certificate" /&gt;
&lt;/Policies&gt;
</code></pre></li>
</ol>

<p>And at the end</p>

<pre><code>&lt;Certificates&gt;
    &lt;EndpointCertificate X509StoreName="MY" X509FindValue="XXXX" Name="Certificate" /&gt;
  &lt;/Certificates&gt;
</code></pre>

<ol start="3">
<li>Added the Endpoint in ServiceManifest.xml with port 443</li>
</ol>

<p>I'm now left with enabling the HTTPS endpoint.
In Program.cs I have this:</p>

<pre><code>  public static void Main(string[] args)
        {
            ServiceRuntime.RegisterServiceAsync("MyType", context =&gt; new WebHostingService(context, "ServiceEndpoint")).GetAwaiter().GetResult();

            Thread.Sleep(Timeout.Infinite);
        }
 internal sealed class WebHostingService : StatelessService, ICommunicationListener
        {
            private readonly string _endpointName;

            private IWebHost _webHost;

            public WebHostingService(StatelessServiceContext serviceContext, string endpointName)
                : base(serviceContext)
            {
                _endpointName = endpointName;
            }

            #region StatelessService

            protected override IEnumerable&lt;ServiceInstanceListener&gt; CreateServiceInstanceListeners()
            {
                return new[] { new ServiceInstanceListener(_ =&gt; this) };
            }

            #endregion StatelessService

            #region ICommunicationListener

            void ICommunicationListener.Abort()
            {
                _webHost?.Dispose();
            }

            Task ICommunicationListener.CloseAsync(CancellationToken cancellationToken)
            {
                _webHost?.Dispose();

                return Task.FromResult(true);
            }

            Task&lt;string&gt; ICommunicationListener.OpenAsync(CancellationToken cancellationToken)
            {
                var endpoint = FabricRuntime.GetActivationContext().GetEndpoint(_endpointName);

                string serverUrl = $"{endpoint.Protocol}://{FabricRuntime.GetNodeContext().IPAddressOrFQDN}:{endpoint.Port}";

                _webHost = new WebHostBuilder().UseKestrel()
                                               .UseContentRoot(Directory.GetCurrentDirectory())
                                               .UseStartup&lt;Startup&gt;()
                                               .UseUrls(serverUrl)
                                               .Build();

                _webHost.Start();

                return Task.FromResult(serverUrl);
            }

            #endregion ICommunicationListener
        }
</code></pre>

<p>How can I register the HTTPS endpoint here?</p>

<p>Adding a second ServiceRuntime.RegisterServiceAsync doesn't work.</p>

<p>Also, After enabling it, how I do install (from the portal or powershell) the certificates from KeyVault to the Virtual Machines Scale sets that are already deployed and running?</p>