0

我有一个作为 Windows 服务运行的 WCF 服务库。我想将此服务迁移为 Azure 辅助角色。当我右键单击 WCF 项目时,我通常会看到“添加 Windows Azure 部署项目”选项。使用我的 WCF 库,我看不到此选项。在这种情况下,如何将 WCF 服务库作为辅助角色迁移到 Azure?任何帮助将不胜感激。

下面是我的 WCF 服务库的 app.config。

<?xml version="1.0"?>
<configuration>
<system.serviceModel>
    <bindings>
        <netTcpBinding>
            <binding name="NetTcpBinding_IHealthService" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
                hostNameComparisonMode="StrongWildcard" listenBacklog="10"
                maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
                maxReceivedMessageSize="65536">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <reliableSession ordered="true" inactivityTimeout="00:10:00"
                    enabled="false" />
                <security mode="None">
                    <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                    <message clientCredentialType="Windows" algorithmSuite="Default" />
                </security>
            </binding>
        </netTcpBinding>
    </bindings>
    <client>
        <endpoint address="net.tcp://localhost:9017/monitor/health/service.svc"
            binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IHealthService"
            contract="HealthService.IHealthService" name="NetTcpBinding_IHealthService" />
    </client>
</system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
</configuration>
4

2 回答 2

1

在这种情况下,我建议您手动创建一个工作角色项目,添加对服务库项目的引用,然后将服务托管在工作角色内部。服务主机代码类似于您为普通控制台/Windows 服务主机获得的代码。但请通过代码获取地址。另外,完整的教程可以参考http://msdn.microsoft.com/en-us/WAZPlatformTrainingCourse_WindowsAzureRoleCommunicationVS2010Lab

此致,

明旭。

于 2012-04-24T06:52:11.683 回答
0

仅当项目类型为 WebApplication 或 WCF 应用程序时,才会显示“添加 Windows Azure 部署项目”选项。您必须在 WebApplication 中托管您的 WCF 库,然后该选项才会出现(或者甚至更好地将其直接托管在 Windows Azure WebRole 项目中)。

如果您真的想在 WorkerRole 中托管您的 WCF 库,我建议您按照 Ming Xu 的解释进行操作。但通常您将 WCF 服务托管在 Windows Azure 上的 WebRoles 中。所以我希望你有一个特殊的需求来解释你为什么要使用 WorkerRoles。

我希望这会有所帮助。

于 2012-06-16T18:33:49.280 回答