Eric Yin
Eric Yin

Reputation: 9003

How to put system.serviceModel into ServiceConfiguration.cscfg (Windows Azure)

I have following code (for Microsoft Translator)

    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_LanguageService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <security mode="None">
                        <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
                        <message clientCredentialType="UserName" algorithmSuite="Default" />
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://api.microsofttranslator.com/V2/soap.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_LanguageService" contract="TranslatorService.LanguageService" name="BasicHttpBinding_LanguageService" />
        </client>
    </system.serviceModel>

It was in web.config and working well. Now I need to put some translate function to Azure Worker Role, so I got error Could not find default endpoint element that references contract 'TranslatorService.LanguageService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.

I already found solution is to put above settings to ServiceConfiguration.cscfg, but how? I tried many location but all error and cannot deploy. Please help

Upvotes: 4

Views: 2210

Answers (1)

Sandrino Di Mattia
Sandrino Di Mattia

Reputation: 24895

The ServiceConfiguration.cscfg can only contain Azure specific configuration (like number of instances, configuration settings, thumbprints, ...).

Whenever you need to do regular .NET configuration (like WCF for example) you can simply create an app.config for your worker role as if you would for a console application and put your configuration in here. Note that the sample configuration in your question isn't complete if you want to add it in the app.config. You should wrap this around it:

<?xml version="1.0"?>
<configuration>

  ...

</configuration>

Upvotes: 5

Related Questions