
Descarga de Strawberry for Perl

Creación del proyecto de Windows Azure


Cuando tenemos un proyecto de este tipo, lo más importante es adjuntar y configurar el interprete que vamos a utilizar para nuestro código. En este caso, vamos a añadir el directorio de strawberry para que el mismo sea subido a Azure junto con nuestra aplicación. La forma más fácil de realizar este paso sería ubicar una copia de la carpeta strawberry en el directorio del proyecto WebCgiRole para posteriormente poder incluirlo.

Modificación de los archivos de configuración
<?xml version="1.0"?>
<configuration>
<system.webServer>
<fastCgi>
<!-- Set the "Enable Full Trust" property to true on the corresponding
Web Role in the Cloud Service project.
-->
<!-- Define the fastCgi application here. The application must be located
under the role root folder or subfolder. The handler is defined in
the Web.config file.
Ensure that all of the handler binaries have their "Build Action" Solution
Explorer file property set to "Content".
<application fullPath="%RoleRoot%approotcgi-handler.exe" arguments="arg1 arg2 ..." />
-->
<application fullPath="E:approotstrawberryperlbinperl.exe"/>
</fastCgi>
</system.webServer>
</configuration>
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<handlers>
<!-- Define your fastCgi handler here. The scriptProcessor value should map to the
application's fullpath and arguments values in the Web.roleconfig file.
<add name="FastGGI Handler"
verb="*"
path="{file or extension, ex: *.php}"
scriptProcessor="%RoleRoot%approotcgi-handler.exe|arg1 arg2 ..."
modules="FastCgiModule"
resourceType="Unspecified" />
-->
<add name="CGI Handler" verb="*" path="*.cgi"
scriptProcessor="E:approotstrawberryperlbinperl.exe % s %s"
modules="CgiModule"
resourceType="Unspecified" />
<add name="PL Handler" verb="*" path="*.pl"
scriptProcessor="E:approotstrawberryperlbinperl.exe % s %s"
modules="CgiModule"
resourceType="Unspecified" />
</handlers>
<defaultDocument>
<files>
<add value="pruebaperl.cgi" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
ISAPI and CGI Restrictions
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="PerlFastCGI" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
<WebRole name="WebCgiRole" enableNativeCodeExecution="true">
<Startup>
<Task commandLine="EnableIsapi.bat" executionContext="elevated" taskType="simple"></Task>
</Startup>
<Sites>
<Site name="Web">
<Bindings>
<Binding name="Endpoint1" endpointName="Endpoint1" />
</Bindings>
</Site>
</Sites>
<Endpoints>
<InputEndpoint name="Endpoint1" protocol="http" port="80" />
</Endpoints>
<Imports>
<Import moduleName="Diagnostics" />
<Import moduleName="RemoteAccess" />
<Import moduleName="RemoteForwarder" />
</Imports>
</WebRole>
</ServiceDefinition>
setlocal enableextensions enabledelayedexpansion set appcmd="%windir%system32inetsrvappcmd" %appcmd% set config -section:isapiCgiRestriction /-[path='"e:approotstrawberryperlbinperl.exe %% s %%s"'] /commit:apphost %appcmd% set config -section:isapiCgiRestriction /+[path='"e:approotstrawberryperlbinperl.exe %% s %%s"'] /commit:apphost %appcmd% set config -section:isapiCgiRestriction /[path='"e:approotstrawberryperlbinperl.exe %% s %%s"'].allowed:true /commit:apphost exit /b 0
Subiendo nuestro proyecto a Windows Azure
Para comprobar que la configuración del proyecto de Windows Azure está definida correctamente, vamos a crear dos nuevos archivos: El primero de ellos se llamará pruebaperl.cgi el cual será ejecutado por defecto cuando entremos en nuestro sitio raíz.
#!/perl
print "Content-type: text/htmlrnrn";
for ($i=1; $i<=10; $i++)
{
print "
<li> - Prueba de ejecucion Iteracion: $i n";
}
El segundo se llamará prueba.pl donde añadiremos el siguiente contenido:
#!/perl
print "Content-type: text/htmlrnrn";
for ($i=1; $i<=10; $i++)
{
print "
<li> - Prueba de ejecucion en pl Iteracion: $i n";
}
Subimos la aplicación al portal de Windows Azure de la forma habitual y esperamos hasta que el estado de la misma se torne a Ready.
Si accedemos al DNS seleccionado deberíamos obtener el siguiente resultado:

Por otro lado, si añadimos a la ruta http://myDNS.cloudapp.net/prueba.pl el resultado esperado sería:

Espero que haya sido de utilidad
¡Saludos!



