Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to commit WebAdministration changes in Azure Web Role

Tags:

iis

azure

I have an Azure Web Role running in the new 1.3 SDK and I am having permissions issues when trying to make changes to IIS using the Microsoft.Web.Administration.ServerManager. Whenever I execute CommitChanges() it throws this error:

an UnauthorizedAccessException "Cannot write configuration file due to insufficient permissions".

My ServerManager code is executing in the OnStart method of the RoleEntryPoint.

My understanding was that the purpose of moving to full IIS support in 1.3 was so that we could have greater control over the configuration of our application, including creating new IIS sites on the fly if desired.

like image 612
Joe Brinkman Avatar asked Dec 21 '10 07:12

Joe Brinkman


2 Answers

Make sure your role is running with elevated privileges.

like image 97
user94559 Avatar answered Nov 10 '22 10:11

user94559


I think there are two questions here. Firstly the use of IIS in Azure. Yes using the 1.3 SDK means that we now have access to more features than we did previously. This means that we can setup more than one site and virtual directories for our sites in the configs as shown in the training kit.

Secondly there is the privileges issue that you're getting while trying to make changes programatically. I'm going to presume that you're not trying to do one of the things that you can simply do through the config above. The most likely reason your code is erroring is because web roles are not run with admin privileges. Fortunately in the 1.3 SDK we also have a way to run code with elevated privileges. As shown elsewhere in the training kit you can create a separate .exe that you specify to be run at startup with elevated privileges in the config.

like image 26
knightpfhor Avatar answered Nov 10 '22 10:11

knightpfhor