Using WCF on Localhost on Azure

后端 未结 2 891
悲哀的现实
悲哀的现实 2021-02-09 02:01

In summary
How do I acces a WCF service on localhost when hosted in IIS on Azure? Azure does not bind localhost or 127.0.0.1 to my website.

2条回答
  •  逝去的感伤
    2021-02-09 02:18

    Okay, so this is how I solved it. IMHO it's a hack but at least it works.

    Basically, I need to add a "*" binding, so I can do this in Powershell. The general recipe is here: http://blogs.msdn.com/b/tomholl/archive/2011/06/28/hosting-services-with-was-and-iis-on-windows-azure.aspx

    That deals with adding Named Pipes support, but the principle is the same. I just changed the Powershell script to:

    import-module WebAdministration
    # Set up a binding to 8080 for the services 
    Get-WebSite "*Web*" | Foreach-Object { 
      $site = $_;
      $siteref = "IIS:/Sites/" + $site.Name;
      New-ItemProperty $siteref -name bindings -value @{protocol="http";bindingInformation="*:8080:"}
    }
    

    This now allows me to use http://127.0.0.1:8080/service.svc to access my service.

    Note: You do need to follow the rest of the recipe to set elevated execution context and change the powershell execution mode, so do follow it carefully

提交回复
热议问题