You really should not change your configurations when you are based on if you are in Prod or Staging. The staging area is not intended for the QA environment, but only the storage area before deployment.
When you download a new deployment, the current deployment slot into which you download your package is destroyed and ends for 10-15 minutes when the virtual machine boots and starts. If you load directly into production, this is 15 minutes of production downtime. Thus, the setting area was created: you load into the stage, check the material and click the "swap" button, and your setting environment magically becomes a production (virtual IP exchange). Thus, your production should be really 100% the same as your production.
What I think you are looking for is a QA / test environment? You must open a new service for the testing environment using your own Prod / Staging. In this case, you will need to support several sets of configuration files, one for each deployment environment (Production, Testing, etc.).
There are many ways to manage the hell configuration, especially with Azure, which has its own * .cscfg files on top of .config files. The way I prefer to do this with an Azure project is as follows: Set up a small Config project, create folders there that match the deployment types. Inside each folder, * .config and * .cscfg files are installed that correspond to the specific deployment environment: Debug, Test, Release ... they are also configured in Visual Studio, as well as target types. I have a small xcopy command that occurs during each compig of the Config project, which copies all the files from the Create Target folder of the Config project to the root folder of the Config project.
Then, every other project in the solution is associated with a .config or .cscfg file from the Config project root folder.
Voila, my configs magically adapt to each build configuration automatically. I also use .config transformations to manage debugging information for Release and non-Release purposes.
If you read all this and still want to get Production vs. Staging at runtime , then: Get the deploymentId from RoleEnvironment.DeploymentId Then use the management API with the correct X509 certificate to get the Azure structure of your Service value and call the GetDeployments method (it remains api, but there is an abstraction library).
Hope this helps
Edit: blog post asking for customization of configuration lines and switching between environments @ http://www.paraleap.com/blog/post/Managing-environments-in-a-distributed-Azure-or-other-cloud-based- NET-solution.aspx