Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure cloud service project configuration (.csdef and .cscfg) in multiple environments

Currently we have a development cloud services (acme-dev-service) and a production cloud service (acme-prod-service). Our current setup in our solution has a cloud service project called acme.application that uses transformation of the .cscfg and .csdef files for deploying the project to the two environments (production and development). I don’t like the transformation method because it feels like a bit of a hack to me. So after doing some research it seems that you can have multiple configuration files which solves some of the issue but I am running into problems because you are only allowed one service definition. This doesn’t work for us because the production environment requires extra certificates as well as different hostHeader bindings than our dev environment does.

So it seems we cant really get away from using the transformations. So I guess my question boils down to am I looking at the Azure Service Project files in the wrong light? Should we really be mapping one Azure Project to one Azure cloud service? Should I have an Azure project for Production and a second Azure Project for Development? Is there a better way to do this? Or a best practice for working with multiple environments in Azure?

like image 587
Colin Pear Avatar asked Jul 11 '13 23:07

Colin Pear


People also ask

Which file specifies the settings that are used by Azure to configure cloud service?

The configuration of the settings for your cloud service is determined by the values in the ServiceConfiguration. cscfg file.

Which of the following configuration file provides the cloud service and individual roles including the number of role instances?

cscfg - The service configuration file configures how many instances of a role are run and the values of the settings defined for a role.

What are the two types of roles available for cloud Services in Azure?

When working with the cloud platform, there are two Azure service roles on which an application can be installed: web roles or worker roles. The main difference between the two is how the VM is hosted: A web role is a Microsoft server VM running Internet Information Services (IIS).

Which is primary configuration file type used in Azure?

Service configurations (. cscfg files) store settings for the deployment environments for an Azure cloud service. Azure uses these configuration files when it manages your cloud services.


1 Answers

The CSDefinition file is the real kicker here. If you have a value you need to be different between two environments (dev/test/stage/production, etc.) then you really have three options:

1) Manually modify the value before a deployment. Errr....Okay....you have two options.

1) Tap into the MS Build process and determine which cloud configuration you have selected (the one used to determine which version of the .cscfg file will be used) and then have the build modify the .csdef after the build and prior to packaging (there is a time when the file has been copied to a different directory just before packaging and this is where you want to make the change). This can be tricky, though I've seen it done and have even done so myself in the early SDK days. Here is a blog post explaining one example where he's using WebConfigTransformRunner to do just that: http://fabriccontroller.net/blog/posts/apply-xdt-transforms-to-your-servicedefinition-csdef-file/. I don't really think this is your best option because it is opaque. It's not evident what is going on and someone who comes along after you to maintain the code will not know about this little gem and will spend forever trying to figure out why some value they put into the csdef somewhere is somehow getting overwritten after they publish to a different environment.

2) Use the two Azure Project approach you mentioned. You can set up build definitions in your Build tool of choice that determine which of the Azure projects you want to build and publish. Personally I think this is the best way to deal with different .csdef files. It's straight forward and doesn't require modifying the csproj files. I'm not opposed to csproj file changing, it's just not overly obvious it was done and, speaking as someone who has inherited things like that, it's not easy to find when people do that kind of thing and they aren't around to tell you about it.

like image 103
MikeWo Avatar answered Sep 19 '22 12:09

MikeWo