且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

是否可以编辑部署在Windows Azure云应用程序的web.config文件而无需重新部署我的应用程序?

更新时间:2022-11-05 13:47:09

在此回答下面的意见根据马克西姆现在已经过时了。

According Maxim in the comments below this answer is now out of date.

您可以通过编程修改Web角色的web.config设置中使用Microsoft.Web.Administration.ServerManager库的OnStart事件。

You can programmatically modify the web.config settings of a web role in the OnStart event using the Microsoft.Web.Administration.ServerManager library.

* 的离开原来的答案,因为它是在时间和为正确,我没有因为回答这个问题使用Azure的,我不是100%确定有效的答案。

* leaving the original answer as it was correct at the time and as, I have not used Azure since answering this question, and I am not 100% sure of the valid answer.

在一个字没有。

您必须使用服务配置文件来完成这些设置。

You must use the service configuration file for such settings.

要决定是否将钥匙在服务配置设置与Web配置设置。

To decide on whether to place keys in the service configuration settings versus web configuration settings.

您可以问自己以下问题:

You could ask yourself the following questions:

是否与每个部署此设置的变化?如果是这样那么的网站的配置设置是此信息的正确位置。

Does this setting change with every deployment? If so then the web configuration settings is the correct place for this information.

将在部署后,该设置的变化?如果是这样那么的服务的配置设置是此信息的正确位置。

Will this setting change after deployment? If so then the service configuration settings is the correct place for this information.

在Web.config文件的部署包的一部分,因此是只读的,当部署到Azure中,以更新,您将需要重新部署的设置。

The Web.config file is part of the deployment package and so is read-only when deployed to Azure, in order to update the settings you will need to redeploy.

而服务配置文件上传的,但不与,部署包包装的,因此,你可以上传或编辑文件,而不用重新部署服务。

Whereas the service configuration file is uploaded with, but not packaged with, the deployment package, and therefore you can upload or edit the file without redeploying your service.