问题
I have a database connectionstring in my Azure cloud service's web role web.config. While developing this is pointing to localhost, but when deployed I want to point my production database. With azure websites you can override web.config settings and connectionstrings using the azure portal but how do I do this with cloud services?
Also, in the new azure portal, it says Cloud Services (classic) , does this mean deprecated? Should I be using a newer azure feature for hosting my soap/rest webservice?
回答1:
With Web Role, you would configure the connection string in the .cscfg files rather than the Web.config file. Then you could change that configuration depending on your environment (ex: ServiceConfiguration.Cloud.cscfg, ServiceConfiguration.Local.cscfg). From the portal, All settings, Configuration will let you change the configuration as described here: https://azure.microsoft.com/en-us/documentation/articles/cloud-services-how-to-configure-portal/.
In terms of deprecation, the new PaaS model for Azure is a continuum from IaaS to PaaS. For instance, Worker Roles v2 would be the VM Scale sets as described by Mark Russinovich in his talk at //build2015. cf slide 19 in the slide view of this talk. Service Fabric will also play an important role. For simpler usages, Web Apps is the way to go.
来源:https://stackoverflow.com/questions/34449761/webconfig-overrides-for-azure-cloud-services