There are several answers (e.g. this and this) and a blog post pointing out how to install the Visual C++ 2010 redistributable packages as part of the deployment of an Azure cloud service.
Firstly you add the vcredist_x64.exe to the web project and set its "Copy to output directory" property to "Copy if newer" or "Copy always". Then you do the same for a command file (in my case "InstallVC.cmd") which contains the single line:
vcredist_x64.exe /q /norestart
Then you edit the ServiceDefinition.csdef file to include the setting
<Startup>
<Task commandLine="InstallVC.cmd" executionContext="elevated" taskType="simple" />
</Startup>
within the role. The answers and the blog post go on to point out that the start-up task will hang if the osFamily setting on the ServiceConfiguration.csfg is set to osFamily="1" and that it needs instead to be set to osFamily="2".
Mine is set to osFamily="4", but the deployment fails. I get the error message Role has encountered an error and has stopped. Application startup task failed with exit code 5100
.
How do you install the the Visual C++ 2010 redistributable packages as part of the deployment of an Azure cloud service using the more recent Azure OS families?
It failed because the Azure cloud service image already had a more up-to-date version of the Visual C++ redistributable packages installed, and so I did not need to install another. What had fooled me into thinking I did need it was that a DLL I use was failing to load its dependencies (as the screenshot below from Dependency Walker shows). But the failure to find the dependencies was not because the Visual C++ redistributable packages were missing, but instead because I was referencing the debug versions (e.g. MSVCP120D.DLL
not MSVCP120.DLL
). Swapping to 'release' fixed the missing dependencies problem for me, without needing any Azure deployment start-up tasks.