我有一个WCF服务库,它作为Windows服务运行。我想将此服务迁移为 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>
在这种情况下,我建议您手动创建一个辅助角色项目,添加对服务库项目的引用,然后在辅助角色中托管服务。服务主机代码类似于普通控制台/Windows 服务主机的代码。但请通过代码获取地址。此外,您可以参考 http://msdn.microsoft.com/en-us/WAZPlatformTrainingCourse_WindowsAzureRoleCommunicationVS2010Lab 以获取完整的教程。
此致敬意
徐明.
仅当项目类型为 Web 应用程序或 WCF 应用程序时,才会显示"添加 Windows Azure 部署项目"选项。您必须在Web应用程序中托管WCF库,然后该选项将出现(或者更好地直接在Windows Azure WebRole项目中托管它)。
如果您确实想在 WorkerRole 中托管 WCF 库,我建议您按照 Ming Xu 解释的操作。但通常,您将WCF服务托管在Windows Azure上的WebRoles中。因此,我希望您有一个特殊的需求,可以解释为什么要使用 WorkerRoles。
我希望这有所帮助。