Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change http.sys registry settings on Windows Azure?

I would need to raise the UrlSegmentMaxLength of the Http.sys registry settings on Windows Azure. Does anyone knows how to do that? (or do something that leads to an equivalent behavior)

like image 637
Joannes Vermorel Avatar asked Dec 23 '22 01:12

Joannes Vermorel


2 Answers

1) Add a .cmd file to your web project. Set Build Action to “None” and Copy to Output Directory to “Copy always”.

2) Update .cmd file. Here is the example script I used which checks to see if the registry change has been set, and if it hasn't modify the registry and then reboot the server (reboot required - simply restarting the http service causes the azure deployment to go in a never ending loop).

@echo off
setlocal
set regpath=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\HTTP\Parameters
reg query "%regpath%" /v "AllowRestrictedChars"
if errorlevel 1 (
   reg add %regpath% /v AllowRestrictedChars /t REG_DWORD /d 00000001
   reg add %regpath% /v UrlSegmentMaxCount /t REG_DWORD /d 00000000
   reg add %regpath% /v PercentUAllowed /t REG_DWORD /d 00000001
   reg add %regpath% /v UrlSegmentMaxLength /t REG_DWORD /d 00000000
   shutdown /r /t 0
)

3) In your Azure role’s servicedefinition.csdef, add the .cmd as a startup task:

<WebRole name="WebRoleName">
  ...
  <Startup>
    <Task commandLine="httpSys.cmd" executionContext="elevated" />
  </Startup>
</WebRole>

4) Deploy your Azure role and the registry changes should have taken place.

like image 67
bkaid Avatar answered Jan 31 '23 04:01

bkaid


It looks like those reg keys are in HKLM. I don't believe you can change those without admin access (which you don't have in Windows Azure today).

Unless there's another way to override that (like in web.config), I think you're out of luck until admin mode comes.

like image 45
user94559 Avatar answered Jan 31 '23 04:01

user94559