How do I enable PUT requests in Azure?

I am creating a REST API on Azure, but when I try to access an endpoint via the PUT method, I get a status HTTP 405 "Method Not Allowed"

along with an IIS error message:

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

How do I enable the PUT method and other methods that might be blocked by default by the Azure default configuration settings?

I tried to add a web.config file to the root of my application with allowUnlisted set to true in the verb element:

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

      

It didn't change anything.

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

Thank!

+3


source to share


3 answers


Add web.config

the system.webServer

following to an item within an item :

<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 built-in PHP versions, the current default is PHP 5.4, but if you selected PHP 5.3 or PHP 5.5 you will need to change the php-cgi handler path.

+9


source


Add this to your web.config/system.webServer

:

<handlers>
  <remove name="ExtensionlessUrl-Integrated-4.0" />
  <add name="ExtensionlessUrl-Integrated-4.0"
       path="*."
       verb="GET,HEAD,POST,DEBUG,DELETE,PUT"
       type="System.Web.Handlers.TransferRequestHandler"
       preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>

      



or instead of specifying which verbs are allowed, say verb="*"

to allow all verbs.

+2


source


To complete the answer given by cory_flower you have to change 54 to the specified version.

Example: 7.2 gives:

<handlers>
  <remove name="PHP72_via_FastCGI" />
  <add name="PHP72_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\v7.2\php-cgi.exe" resourceType="Either" requireAccess="Script" />
</handlers>

      

Pretty trivial, but for information only

Update: fixed path

+1


source







All Articles