iefpw
iefpw

Reputation: 7062

Changing cloud service web.config at runtime

I'm trying to change the web.config of a deployed cloud service (WCF in this case) on Windows Azure, and when I try to change the appSettings in the web.config at runtime, I'm getting permission denied error:

Access to the path 'E:\sitesroot\0\web.config' is denied.

Is there a way to fix this?

Upvotes: 1

Views: 992

Answers (3)

maddog
maddog

Reputation: 194

Jonny S is right. You should store settings you want to change at runtime in the role configuration. The web.config changes will be lost if Azure moves your VM and in a multi-instance scenario your instances will be out of sync. You can use roleenvironmentchanging event to manage how a role instance responds to a configuration change.

For more info on roleenvironmentchanging event check http://msdn.microsoft.com/en-us/library/windowsazure/gg432963.aspx

Upvotes: 5

QFDev
QFDev

Reputation: 9008

If you RDP into the web role you should be able to add permissions to the web.config file for the logged in user. You can then modify the web.config. As @Adil mentions this will cause the AppDomain to recycle so should only really be done as a last resort.

Upvotes: -3

Jon Susiak
Jon Susiak

Reputation: 4978

You should store any settings you need to change at runtime in the ServiceConfiguration (cscfg) of your Role and then use the following in your code to retrieve the setting:

string setting = RoleEnvironment.GetConfigurationSettingValue("myConfigSetting");

You can change the values in the ServiceConfiguration through the Management Portal once deployed.

Upvotes: 2

Related Questions