title: Azure API Management: Doing a global policy for set-backend-service results in scope error
body: <p>So globally on my API service, I always wish to set the backend service URL based on certain calling regions.</p>
  
  <p>According to this <a href="https://msdn.microsoft.com/library/azure/7406a8ce-5f9c-4fae-9b0f-e574befb2ee9?f=255&amp;MSPPError=-2147217396#SetBackendService" rel="nofollow noreferrer">MSDN library article</a>, using the set-backend-service policy sounds perfect for this, and it's a global policy according to its policy scope at the bottom.</p>
  
  <p>However, even posting their exact example... </p>
  
  <pre><code>&lt;policies&gt;
      &lt;inbound&gt;
          &lt;choose&gt;
              &lt;when condition="@(context.Request.Url.Query.GetValueOrDefault("version") == "2013-05")"&gt;
                  &lt;set-backend-service base-url="http://contoso.com/api/8.2/" /&gt;
              &lt;/when&gt;
              &lt;when condition="@(context.Request.Url.Query.GetValueOrDefault("version") == "2014-03")"&gt;
                  &lt;set-backend-service base-url="http://contoso.com/api/9.1/" /&gt;
              &lt;/when&gt;
          &lt;/choose&gt;
      &lt;/inbound&gt;
  </code></pre>
  
  <p>....results in an error:</p>
  
  <blockquote>
    <p>"Error in element 'set-backend-service' on line 0, column 0: Policy is
    not allowed in the specified scope"</p>
  </blockquote>
  
  <p>I can't figure out how to make it any simpler of a situation to troubleshoot.  I even removed the conditional statement and just left the policy alone and it still shows the scope error.</p>
  
  <p>I know this global scope works okay, since I was able to put in an xml-to-json policy as a temporary test and save successfully.</p>
  
  <p>I would figure someone ran into this issue already, as this must be a common use case for this policy.  Otherwise, I think the MSDN article is out of date, unless anyone here can see any issues.</p>
  
  <p>Here's my policy scope for global:
  <a href="https://i.stack.imgur.com/jzwkX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jzwkX.png" alt="enter image description here"></a></p>