1

I do realise that his question was asked and answered, but unfortunately the solution of complete clean, rebuild, restart.. doesn't work in my case and my lowly reputation doesn't allow me to comment. So I am I think compelled to ask it again with my info. Sample code:

    CloudStorageAccount storageAccount;
    string settings = CloudConfigurationManager.GetSetting("StorageConnectionString");
    storageAccount = CloudStorageAccount.Parse(settings);

I have my web.config section like this:

  <appSettings>
    <add key="owin:AppStartup" value="zzzz" />
    <add key="webpages:Version" value="3.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
    <add key="StorageConnectionString" value="DefaultEndpointsProtocol=https;AccountName=xxxx;AccountKey=yyyy"/>
  </appSettings>

In the ServiceConfiguration.Cloud.cscfg I have:

<ConfigurationSettings>
  <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="DefaultEndpointsProtocol=https;AccountName=nnnn" />
  <Setting name="StorageConnectionString" value="DefaultEndpointsProtocol=https;AccountName=xxxx;AccountKey=yyyy"/>
</ConfigurationSettings>

and in the ServiceConfiguration.Local.cscfg I have:

   <ConfigurationSettings>
      <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />
      <Setting name="StorageConnectionString" value="UseDevelopmentStorage=true" />
    </ConfigurationSettings>

I converted this to an Azure project from a standard MVC web project in order to use the Azure storage blobs etc. I am finding that no matter what I seem to do it always uses the Azure storage.

As I step through the code snippet above.. I can clearly see the returned connection string as the one coming from the web.config app setting... I feel I must be doing something fundamentally wrong or missing something..? A small point (maybe?) as I converted the project over, there was an error message (on a pop up and not saveable) about a connection string error and it not working. I hadn't even created this particular connection string at that time and the only other one (for localDB does work). That however is in the web.config section and as it ain't broke I didn't fix it to go into the .. Any help would be appreciated.

Further Addition, from the comments by Igorek below, I did check the Role settings and they appear to be correct. Then .. after a lot of messing around, some experiments which still didn't work, I've taken a step back. I actually don't want a cloud service, I ended up with one because I thought I needed one to access Blobs and Queues, I had already decided that WebJobs seems like the way to go first to keep as abstracted as possible. So I have rolled back to prior to the Web SITE that I had before and found but I still CAN'T seem to get it to use development storage.. although I imagine that CLoudConfigurationManager probably doesn't handle Web Sites? Any tips?

Brett JB
  • 687
  • 7
  • 24
  • Which one is the starting project in your solution: Cloud service one or the web application? – Gaurav Mantri Jul 08 '14 at 16:32
  • The cloud service one.. (I think - gleaned from rt click on solution - set startup projects. The 'Single startup project' radio button is selected and the sitename.azure is selected. – Brett JB Jul 08 '14 at 21:08

1 Answers1

1

Check into settings of your Role within the cloud project. It will have a default for which configuration it starts with. Simply swap from Cloud to Local.

Igorek
  • 15,716
  • 3
  • 54
  • 92
  • Thanks for that, I tried to ad a screen shot in the update above to show that I think I have that correct. You did spur me to try the experiment though and that shows something else is going on. – Brett JB Jul 09 '14 at 08:51
  • To clarify on this answer, right click on your Cloud Service project (not the Roles, but the project) and Properties. Then go to Development tab (from left), and you will see "Service Configuration" setting under Run/Debug category. This needs to be Local for Cloud Service project to use Local setting – stack247 Jun 14 '15 at 15:32