Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I enable PUT requests in Azure?

I'm building a REST API on Azure, but when I try to access an endpoint via the PUT method I get a HTTP 405 "Method Not Allowed" status along with an IIS error message:

The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used.

How do I enable the PUT method, and other methods that may be blocked by default by Azure's default config settings?

I tried adding a web.config file to the root of my application with allowUnlisted set to true on the verbs element:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
   <system.webServer>
      <security>
         <requestFiltering>
            <verbs applyToWebDAV="false" allowUnlisted="true" />
         </requestFiltering>
      </security>
   </system.webServer>
</configuration>

This changed nothing.

I'm an open source guy, so the world of IIS is very unfamiliar to me. Any help is appreciated.

Thanks!

like image 488
dtrenz Avatar asked Dec 01 '22 18:12

dtrenz


1 Answers

Add the following to the web.config in the system.webServer element:

<handlers>
  <remove name="PHP54_via_FastCGI" />
  <add name="PHP54_via_FastCGI" path="*.php" verb="GET, PUT, POST, HEAD, OPTIONS, TRACE, PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK" modules="FastCgiModule" scriptProcessor="D:\Program Files (x86)\PHP\v5.4\php-cgi.exe" resourceType="Either" requireAccess="Script" />
</handlers>

This works for the built in versions of PHP, the current default is PHP 5.4, but if you have selected PHP 5.3 or PHP 5.5 you will need to modify the path of the php-cgi handler.

like image 91
cory-fowler Avatar answered Dec 04 '22 03:12

cory-fowler