คำตอบ where to save configuration settings for Azure Roles?

  • 17 สิงหาคม 2555 7:49
     
     

    hi,

    I have two roles(web+worker) in my Azure Compute...and those two roles has some connection settings...which was saved in web.config and app.config...

    Now i want change the connection settings... How do i change the settings of deployed roles in Azure?


    bin hex

ตอบทั้งหมด

  • 17 สิงหาคม 2555 8:10
     
     คำตอบ

    Ideally the settings for a web/worker role should be saved in role's configuration file (*.cscfg) because you can modify the settings in this file on the fly without redeploying your entire application. app.config and web.config files gets bundled into the package and any changes to these would require repackaging and redeployment.

    • เสนอเป็นคำตอบโดย Veerendra Kumar 17 สิงหาคม 2555 9:15
    • ทำเครื่องหมายเป็นคำตอบโดย Bin Hex 17 สิงหาคม 2555 9:33
    •  
  • 17 สิงหาคม 2555 9:14
     
     คำตอบ มีโค้ด

    You can use service configuration for you regular application settings and you might want to change in future. But you need to be aware that whenever you modify service config your role would restart. To handle this you can handle the change in the role environment changing event.

    One more thing you need to be aware here is, you cannot use traditional way of reading config elements from web.config. You need to use role config service run time reference and read the config values. Example is given below.

    RoleEnvironment.GetConfigurationSettingValue("mysetting")

    This approach works well for your application settings. If you have settings like identity foundation which must be in web.config and can't be changed service config, you need to work a bit to let the configuration elements added to service config and add them dynamically to web.config.

    There is a very nice blog written on this, please refer to it.

    If you just have the need to migrating only application settings to role config you can go with first approach. If you have any need that configs must be in web.config you can adopt 2nd method. Also it could be hybrid if you have mixed settings.

    Hope it helps



    Please mark the replies as Answered if they help and Vote if you found them helpful.

    • เสนอเป็นคำตอบโดย Veerendra Kumar 17 สิงหาคม 2555 9:14
    • ทำเครื่องหมายเป็นคำตอบโดย Bin Hex 17 สิงหาคม 2555 9:34
    •  
  • 17 สิงหาคม 2555 9:15
     
     

    Hi Gaurav,

     How can i modify the cscfg file in azure compute?


    bin hex

  • 17 สิงหาคม 2555 9:20
     
     คำตอบ

    There're many ways to do that. Essentially the configuration file is an XML file like your app.config or web.config.

    1. You can do that in the portal itself. In the new portal, for your cloud service click on the "Configure" tab. I think currently it allows you to only edit the existing configuration settings. To add new settings, you would need to download that file and edit it manually.

    2. You can manually edit the configuration file on your computer and then just upload the latest configuration file through portal or using some 3rd party tools like Cloud Storage Studio or using Service Management REST API.

    Hope this helps.

    • ทำเครื่องหมายเป็นคำตอบโดย Bin Hex 17 สิงหาคม 2555 9:34
    •  
  • 17 สิงหาคม 2555 9:32
     
     คำตอบ

    Here is the screenshot from the new portal. Go to your serivce role and click on Configure. You can do inline edit of your settings.

    For your old portal here is the setting.



    Please mark the replies as Answered if they help and Vote if you found them helpful.

    • ทำเครื่องหมายเป็นคำตอบโดย Bin Hex 17 สิงหาคม 2555 9:53
    •  
  • 17 สิงหาคม 2555 9:34
     
     
    Thank you for detailed reply and further guidence....

    bin hex