0

私はAzureでサービスファブリッククラスタをセットアップし、2つのサービスを実行しているアプリケーションを持っています。今私はlocalhost上で実行できるように、ブラウザのサービスに接続できるようにしたい。 アプリケーションはOwinとSwaggerを使用します。 localhostでの実行方法は次のとおりです。running on localhost Azureから接続しようとすると、タイムアウトエラーが発生します。アプリケーションでポート20002と20001を使用しています。クラスタを設定すると(ポート19000,19080,20001,20002がクラスタ内で開いています)、ポートを開いています。エクスプローラでの私のサービスはService in the explorerです。クラスタに証明書のセキュリティが設定されています。証明書がブラウザに追加されています(エクスプローラに接続するために使用しています)。 CreateServiceInstanceListenersのための私のコード:サービスファブリックアプリケーションエンドポイントに接続

 protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners() 
    { 
     return Context.CodePackageActivationContext.GetEndpoints() 
      .Where(endpoint => endpoint.Protocol.Equals(EndpointProtocol.Http) || endpoint.Protocol.Equals(EndpointProtocol.Https)) 
      .Select(endpoint => new ServiceInstanceListener(serviceContext => new OwinCommunicationListener("", new Startup(), serviceContext))); 
    } 

メソッドおよびopenAsyncのための私のコード:

 public OwinCommunicationListener(string appRoot, IOwinAppBuilder startup, StatelessServiceContext serviceInitializationParameters) 
    { 
     _startup = startup; 
     _appRoot = appRoot; 
     _parameters = serviceInitializationParameters; 
    } 


    public Task<string> OpenAsync(CancellationToken cancellationToken) 
    { 
     var serviceEndpoint = 
      _parameters 
      .CodePackageActivationContext 
      .GetEndpoint("ServiceEndpoint"); 

     var port = serviceEndpoint.Port; 
     var root = 
      String.IsNullOrWhiteSpace(_appRoot) 
      ? String.Empty 
      : _appRoot.TrimEnd('/') + '/'; 


     //TODO: Make localhost configable 
     _listeningAddress = String.Format(
      CultureInfo.InvariantCulture, 
      "http://+:{0}/{1}", 
      port, 
      root 
     ); 
     _serverHandle = WebApp.Start(
      _listeningAddress, 
      appBuilder => _startup.Configuration(appBuilder) 
     ); 

     var publishAddress = _listeningAddress.Replace(
      "+", 
      FabricRuntime.GetNodeContext().IPAddressOrFQDN 
     ); 

     ServiceEventSource.Current.Message("Listening on {0}", publishAddress); 
     return Task.FromResult(publishAddress); 
    } 

と私のServiceEndpoint:

<Endpoints> 
    <Endpoint Name="ServiceEndpoint" Port="20002" /> 
</Endpoints> 

私の質問総括する:どのように私は私のサービスファブリックアプリケーションをアクセスもできます私のブラウザのサービスは、すごく使いましたか?

+0

フォワードの内部ポートに(任意の)外部ポートでありますロードバランサ上の20002 – Mardoxx

答えて

1

最も良い方法は、ポート19081でリバースプロキシを使用することです。クラスタ作成時にリバースプロキシを有効にする必要があります。

リバースプロキシのロードバランサルールを設定する必要があります。 Azureのロードバランサ上のサービス・ファブリックの 基本的なセットアップは、しかし、あなたが例えばその後19000.

のルールをコピーすることができ、TCPポート19081のためのルールを持っていない:

  • アプリケーション名はSampleAppです
  • あなたのサービス名は、あなたが正常に http://localhost:20002/api/values
  • パブリックIP fでローカルにあなたのサービスに到達ポート20002
  • でホストSampleService ですまたはクラスタは、次に51.140.xx.xx

今あなたが http://51.140.xx.xx:19081/SampleApp/SampleService/api/valuesであなたのサービスに到達することができます(あなたがリバースプロキシエンドポイントを保護いけない推測)

関連する問題