56

When I run a Windows Azure web role on my local developer fabric, I get the following error:

The current service model is out of sync. Make sure both the service configuration and definition files are valid.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Tariq
  • 1,449
  • 2
  • 14
  • 17

11 Answers11

60

One of my colleagues hit this issue and after a bit of playing about, the problem was that the two service configuration files (cloud and local) had a different number of Settings.

When he updated the configuration files so that they were in sync it all worked.

A tip would be to use the GUI in Visual Studio to add new settings to both at the same time. The GUI can be accessed by right clicking the web role and selection properties. This should open up a window. Click the Settings tab on the left.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Tariq
  • 1,449
  • 2
  • 14
  • 17
12

For me, this was caused by my azure project having been copied from one PC to another (going from Win 7 to Win 8.1 in the process). I am using VS 2013 Community edition on both, but I had upgraded from Azure 2.4 on Win7 to Azure 2.5 on the Win 8.1 machine.

If you unload the azure project and edit the csproj file, you just need to make a small edit (e.g. adding a comment) and save it, so it re-writes itself. This fixed it in my case (where I'd spent ages checking for errors in the CSDEF and CSCFG files). Once I re-saved the csproj file, it worked fine.

Astravagrant
  • 685
  • 10
  • 18
  • 2
    Thanks Astravagant. I didn't have the same history, but your suggestion of touching the ccproj fixed it for me. – Concrete Gannet Jun 04 '15 at 02:03
  • Ditto - I did not copy the project. In fact, I have no idea how this started (I suspect windows patching), but your resolution was the fix. Thanks! – maplemale Sep 29 '15 at 20:25
  • Similar issue. For me the fix was making the above change to the CCPROJ file. Thanks! – bornSwift May 06 '17 at 22:50
11

This happened to me because one of my cloud configuration files (.cscfg) was missing some key-value pairs that were defined in ServiceDefinition.csdef.

Going over the files manually was a pain. There's an easy way to discover the descrepancies:

  1. In the Solution Explorer, right-click one of the Roles that make up your Cloud Service and click 'Properties' in the context menu.

    enter image description here

  2. The Role properties window will open up grey with an error message saying:

    "Invalid Service Definition or service configuration. Please see the Error List for more details".

  3. Open the Error List window and in some cases you should be able to see a list of the specific discrepancies, complete with file and property names.

    enter image description here

urig
  • 16,016
  • 26
  • 115
  • 184
  • 2
    Good tips, but just FYI this doesn't always list the errors (it didn't in my case). I had to search manually until I spotted an inconsistency in the azure project file, which I've added in my answer on this page. – Astravagrant Jan 21 '15 at 11:59
11

I followed all the answers here and it still didn't work eventually I restarted Visual Studio and it worked.

I believe the solution was the combination of one or more of the answers here + restarting VS.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
danfromisrael
  • 2,982
  • 3
  • 30
  • 40
  • 3
    Struggled with this one for a bit. Simply restarting VS2015 (Enterprise) resolved the issue. – Lars Dec 22 '15 at 16:16
8

What worked for me was to:

  1. Make sure the Cloud Services .cscfg and .Local.cscfg files were identical (unless you need your Local.cscfg to have some differences for debugging purposes),
  2. Make sure the .csdef file had definitions that matched the .cscfg files, and then
  3. Close the project and delete its Cloud Services .ccproj.user file.

After reloading the project, all was well.

MQuiggGeorgia
  • 729
  • 1
  • 7
  • 10
  • 1
    On top of these, I also had to delete all generated folders. (bin, csx, obj, rcf, ..) – Iain May 24 '16 at 10:36
4

The error can occour when there is no actual fault in the service configurations. If it occours and everything seems to be correct, instead of restarting visual studio, simply unload the azurecloud project (rightclick: unload proecjt

Jalatiphra
  • 248
  • 1
  • 10
1

Please cross check your ServiceConfiguration.Cloud.cscfg and ServiceConfiguration.Local.cscfg files. My problem was, I added a configuration to Local.cscfg but forgot to add the same to Cloud.cscfg

rebornx
  • 407
  • 6
  • 21
0

My problem was incorrect certificate definition in csdef file.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
SoftwareFactor
  • 8,430
  • 3
  • 30
  • 34
0

Had this issue - no errors though. I have found that for some bizarre reason the if the setting:

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

was commented out, then the workerrole would not launch.

amythn04
  • 388
  • 2
  • 11
0

For me the problem was that the Wifi I was using blocked the PORT Azure is using, changing Wifi solved that problem.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Guy Ben-Moshe
  • 874
  • 1
  • 15
  • 23
0

For me, the issue turned out to be an inconsistency between the vmName value I had assigned to one of my roles in my various environments. I have a *.cscfg files for my development, test, and production environments. Each of these had a role definition that was supposed to be along the lines of

   <Role name="HardWorker" vmName="SomeName">...</Role> 

but one had an entry like

   <Role name="HardWorker" vmName="SomeOtherName">...</Role> 

and that, apparently, was enough to trigger the error.

Bernard Hymmen
  • 825
  • 1
  • 7
  • 14