0

We are trying move our web services from Azure Cloud Services to Azure Web Apps and that would change their address but we have some clients that we are not able to update the address they are using, so we are looking for a way to use the current cloud services server as a message forwarding server for those clients.

I am not an IIS admin so I tried to do some search and find out how to do it with ARR and URL Rewrite but it doesn't seem to work, so I am thinking even if this is the right approach to begin with!

I have enabled Proxy in ARR and created a rewrite rule in IIS for my app. Here is the result rewrite rule in web.config of the old address:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <outboundRules>
                <preConditions>
                    <preCondition name="ResponseIsHtml1">
                        <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                    </preCondition>
                </preConditions>
            </outboundRules>
            <rules>
                <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                    <match url="(.*)" />
                    <action type="Rewrite" url="http://new-address.azurewebsites.net/{R:1}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

Is this the proper way to achieve this? Or do I need to look into solving the issue another way?

Thanks in advance.

0

Fixed the problem by using RoutingService instead of AAR and Url rewrite! Just had to add a web.config file in the empty folder and done!

<?xml version="1.0"?>
<configuration>
<system.serviceModel>
  <serviceHostingEnvironment multipleSiteBindingsEnabled="true">
    <serviceActivations>
      <add factory="System.ServiceModel.Activation.ServiceHostFactory" relativeAddress="./MyService.svc" 
            service="System.ServiceModel.Routing.RoutingService,System.ServiceModel.Routing, version=4.0.0.0, Culture=neutral,PublicKeyToken=31bf3856ad364e35" />
    </serviceActivations>
  </serviceHostingEnvironment>
  <services>
    <service name="System.ServiceModel.Routing.RoutingService" behaviorConfiguration="DefaultServiceBehavior">
      <endpoint name="basicHttpSampleService" address="" binding="wsHttpBinding" bindingConfiguration="sslBinding" contract="System.ServiceModel.Routing.IRequestReplyRouter" />
      <endpoint address="mex" binding="mexHttpsBinding"  contract="IMetadataExchange" />
    </service>
  </services>
  <behaviors>
  <serviceBehaviors>
    <behavior name="DefaultServiceBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
      <routing filterTableName="routingFilterTable" routeOnHeadersOnly="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<routing>
  <filters>
    <filter name="AddressFilter" filterType="MatchAll"/>
  </filters>
  <filterTables>
    <filterTable name="routingFilterTable">
      <add filterName="AddressFilter" endpointName="basicHttpSampleServiceClient"/>
    </filterTable>
  </filterTables>
</routing>
<bindings>
  <wsHttpBinding>
        <binding name="sslBinding" receiveTimeout="00:05:00" sendTimeout="00:05:00" maxReceivedMessageSize="2147483647">
          <security mode="Transport">
            <transport clientCredentialType="None" />
          </security>
          <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" />
        </binding>
      </wsHttpBinding>
</bindings>
<client>
  <endpoint address="http://new-address.azurewebsites.net/MyService.svc"
    binding="wsHttpBinding" bindingConfiguration="sslBinding"
    contract="*" name="basicHttpSampleServiceClient" />
</client>
</system.serviceModel>
</configuration>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.