2016-04-28 6 views
2

ローカルサービスファブリック(GAバージョン)でホストされているmyのためのhttpsエンドポイントがステートレスWeb APIサービスでホストされます。それを達成した後、私はAzureに自分のクラスタを展開したい。HTTPSエンドポイントを使用するステートレスWeb APIサービスで正常性状態エラーが発生する

サービスファブリックのドキュメント「Secure a Service Fabric cluster」の手順に従って、自己署名入りの証明書を作成し、それを鍵のボールトにアップロードしました。また、ステップ2.5でImport-PfxCertificateコマンドを使用して、自分の証明書を自分のマシンの「信頼できる人」ストアにインポートしました。

AddCertToKeyVault:

Invoke-AddCertToKeyVault -SubscriptionId <Id> -ResourceGroupName 'ResourceGroupName' -Location 'West Europe' -VaultName 'VaultName' -CertificateName 'TestCert' -Password '****' -CreateSelfSignedCertificate -DnsName 'www.<clustername>.westeurope.cloudapp.azure.com' -OutputPath 'C:\MyCertificates' 

今私は(RunAs: Run a Service Fabric application with different security permissionsのように)ApplicationManifest.xmlServiceManifest.xmlを調整して、私のOwinCommunicationListener.cs

ServiceManifest.xml(MasterDataServiceWebApi):

<?xml version="1.0" encoding="utf-8"?> 
<ServiceManifest Name="MasterDataServiceWebApiPkg" 
       Version="1.0.0" 
       xmlns="http://schemas.microsoft.com/2011/01/fabric" 
       xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <ServiceTypes> 
    <StatelessServiceType ServiceTypeName="MasterDataServiceWebApiType" /> 
    </ServiceTypes> 

    <CodePackage Name="Code" Version="1.0.0"> 
    <EntryPoint> 
     <ExeHost> 
     <Program>MasterDataServiceWebApi.exe</Program> 
     </ExeHost> 
    </EntryPoint> 
    </CodePackage> 

    <ConfigPackage Name="Config" Version="1.0.0" /> 

    <Resources> 
    <Endpoints> 
     <Endpoint Name="ServiceEndpoint" Type="Input" Protocol="https" Port="5030" CertificateRef="TestCert"/> 
    </Endpoints> 
    </Resources> 
</ServiceManifest> 

ApplicationManifest:

<?xml version="1.0" encoding="utf-8"?> 
<ApplicationManifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ApplicationTypeName="exCHANGETestCluster2Type" ApplicationTypeVersion="1.0.0" xmlns="http://schemas.microsoft.com/2011/01/fabric"> 
    <Parameters> 
     <Parameter Name="MasterDataServiceWebApi_InstanceCount" DefaultValue="-1" /> 
    </Parameters> 
    <ServiceManifestImport> 
     <ServiceManifestRef ServiceManifestName="MasterDataServiceWebApiPkg" ServiceManifestVersion="1.0.0" /> 
     <ConfigOverrides /> 
     <Policies> 
     <EndpointBindingPolicy EndpointRef="ServiceEndpoint" CertificateRef="TestCert" /> 
     </Policies> 
    </ServiceManifestImport> 
    <DefaultServices> 
     <Service Name="MasterDataServiceWebApi"> 
     <StatelessService ServiceTypeName="MasterDataServiceWebApiType" InstanceCount="[MasterDataServiceWebApi_InstanceCount]"> 
      <SingletonPartition /> 
     </StatelessService> 
     </Service> 
    </DefaultServices> 
    <Certificates> 
     <EndpointCertificate X509FindValue="<Thumbprint>" Name="TestCert" /> 
    </Certificates> 
</ApplicationManifest> 

OwinCommunicationListener.cs:

[...] 
public Task<string> OpenAsync(CancellationToken cancellationToken) 
    { 
     var serviceEndpoint = this.serviceContext.CodePackageActivationContext.GetEndpoint(this.endpointName); 
     int port = serviceEndpoint.Port; //NEW! 

     if (this.serviceContext is StatefulServiceContext) 
     { 
     [...] 
     } 
     else if (this.serviceContext is StatelessServiceContext) 
     { 
     var protocol = serviceEndpoint.Protocol; 

     this.listeningAddress = string.Format(
      CultureInfo.InvariantCulture, 
      //"http://+:{0}/{1}", 
      "{0}://+:{1}/{2}", //NEW! 
      protocol, 
      port, 
      string.IsNullOrWhiteSpace(this.appRoot) 
       ? string.Empty 
       : this.appRoot.TrimEnd('/') + '/'); 
     } 
     else 
     { 
     throw new InvalidOperationException(); 
     } 
[...] 

私は今、私のローカルクラスタにステートレスなサービスを展開するとき、私のサービス・ファブリック・エクスプローラは、いくつかの非常に "表現力" のエラーとIを報告します私のサービスにアクセスできません:

Kind  Health State Description 
============================================================================= 
Services Error   Unhealthy services: 100% (1/1), ServiceType='MasterDataServiceWebApiType', MaxPercentUnhealthyServices=0%. 
Service  Error   Unhealthy service: ServiceName='fabric:/sfCluster/MasterDataServiceWebApi', AggregatedHealthState='Error'. 
Partitions Error   Unhealthy partitions: 100% (1/1), MaxPercentUnhealthyPartitionsPerService=0%. 
Partition Error   Unhealthy partition: PartitionId='e5635b85-3c23-426b-bd12-13ae56796f23', AggregatedHealthState='Error'. 
Event  Error   Error event: SourceId='System.FM', Property='State'. Partition is below target replica or instance count. 

Visual Stu dioはそれ以上のエラーの詳細を私に提供していません。それは全く反対です。スタックトレースは次のように表示されます。fabric:/sfCluster/MasterDataServiceWebApi is ready.

私は何を欠席しましたか?私は何か問題を構成しましたか?ところで

:その後、私は私の自己署名証明書を使用して、Azureの中に新しいクラスタを作成したが、私はこのクラスタのサービスファブリックエクスプローラをアセスしようとすると、UIや空白のサイト全くない。..

答えて

3

私は、Service Fabricが証明書の検証にローカルマシンストアを使用していることを知りました。 (https://github.com/Azure-Samples/service-fabric-dotnet-web-reference-app/issues/3

だから私はこのわずかに変更されたのPowerShellスクリプトで私のローカルマシンストアに証明書をインポートする必要がありました:

Import-PfxCertificate -Exportable -CertStoreLocation cert:\localMachine\my -FilePath C:\MyCertificates\TestCert.pfx -Password (Read-Host -AsSecureString -Prompt "Enter Certificate Password") 

は、その前に、私はCert:\CurrentUser\TrustedPeopleCert:\CurrentUser\Myに私の証明書をインポートしました。しかし、ローカルのService Fabricクラスタはそこを参照しません。

BTW: 同じ認証キーを使用してセキュリティ保護されている、空のホストされたサービスファブリッククラスタのサービスファブリックエクスプローラにアクセスしようとすると、まだ空白のサイトが表示されます。私はこの問題の別の質問を作成します。 編集: Firefoxの代わりにInternet Explorerを使用すると、空白のサイトの問題が解決されました。

関連する問題