6

I'm building a simple PHP web service using Azure Web Sites and I'm having trouble getting it to support PUT and DELETE http methods. Assuming it's something that'll have to go into the web.config file - I've tried a few options from around the interwebs but non of them seem to function properly. Any ideas?

Here's the web.config file as it currently stands:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <handlers>
    </handlers>
    <security>
    </security>
    <directoryBrowse enabled="false" />
    <caching>
      <profiles>
        <add extension=".php" policy="DontCache" kernelCachePolicy="DontCache" />
        <add extension=".html" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="14:00:00" />
      </profiles>
    </caching>
    <rewrite>
      <rules>
        <rule name="block favicon" stopProcessing="true">
          <match url="favicon\.ico" />
          <action type="CustomResponse" statusCode="404" subStatusCode="1"
          statusReason="The requested file favicon.ico was not found"
          statusDescription="The requested file favicon.ico was not found" />
        </rule>
        <rule name="Cols Rule" stopProcessing="true">
          <match url="^(.*)$" ignoreCase="false" />
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
            <add input="{URL}" pattern="^/favicon.ico$" ignoreCase="false" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
          </conditions>
          <action type="Rewrite" url="index.php?q={R:1}" appendQueryString="true" />
        </rule>
      </rules>
    </rewrite>
    <defaultDocument>
      <files>
        <remove value="index.php" />
        <add value="index.php" />
      </files>
    </defaultDocument>
  </system.webServer>
</configuration>
Daniel Sharp
  • 191
  • 1
  • 11
  • I saw a similar thread a few days ago. In that case, it turned out that PUT verb was blocked by the internal network. Can you check if that's not the case here? – Gaurav Mantri Apr 09 '13 at 17:36

2 Answers2

4

I do not see that you have handler added into your web.config. I haven't personally tested but someone suggested that PUT and DELETE should work with Windows Azure Website however you would need to configure them correctly on your Windows Azure Websites through web.config.

Following is the simple configuration you can use to set it up:

<configuration>
 <system.webServer>
    <handlers>
        <remove name="PHP53_via_FastCGI" />
        <add name="PHP53_via_FastCGI" path="*.php"
               verb="GET, PUT, POST, HEAD, DELETE" 
               modules="FastCgiModule" 
               scriptProcessor="D:\Program Files (x86)\PHP\v5.3\php-cgi.exe"
               resourceType="Either" requireAccess="Script" />
    </handlers>
 </system.webServer>
</configuration>
AvkashChauhan
  • 20,192
  • 3
  • 31
  • 64
4

It didn't work with DELETE as the last option, and here's the code modified for PHP54 on Azure. But thanks to Avkash!

<handlers> 
    <remove name="PHP54_via_FastCGI" />
        <add name="PHP54_via_FastCGI" path="*.php"
               verb="GET, PUT, POST, DELETE, HEAD" 
               modules="FastCgiModule" 
               scriptProcessor="D:\Program Files (x86)\PHP\v5.4\php-cgi.exe"
               resourceType="Either" requireAccess="Script" />
    </handlers>
Daniel Sharp
  • 191
  • 1
  • 11