'Azure web role build error: "Unable to import module Diagnostics. No manifest was found"
We have a C# web application solution configured to run on Azure cloud services. It's an old solution and builds fine locally on other engineers' laptops (has done for years), and on my previous laptop. But I have a new laptop where I've set up my development environment but this particular solution does not build.
There are two related build errors:
Unable to import module Diagnostics. No manifest was found.in _ServiceDefinition.csdef _(part of the ccproj project)CloudServices58 : Cannot load imported module named 'Diagnostics.'at C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VisualStudio\v17.0\Windows Azure Tools\2.9\Microsoft.WindowsAzure.targets
The ServiceDefinition.csdef file includes this section:
<Imports>
<Import moduleName="Diagnostics" />
<Import moduleName="RemoteAccess" />
<Import moduleName="RemoteForwarder" />
</Imports>
If I remove that first Import line then the build succeeds.
I've searched everywhere for a solution. There are a couple of similar questions here on SO but the answers usually come down to installation of Azure SDK, but I can confirm I have this installed at this location:
C:\Program Files\Microsoft SDKs\Azure.NET SDK\v2.9
I've run out of options. Can any of you help?
Solution 1:[1]
Please check the steps if helps to work around:
Check the
Import Module Diagnostics Codeis under the WebRole inServiceDefinition.csdeffile.Configure
Web.configfile to add Diagnostics Module for Listeners type like:
<system.diagnostics>
<trace>
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener,
Microsoft.WindowsAzure.Diagnostics,
Version=1.0.0.0,
Culture=neutral,
PublicKeyToken=31bf3856ad364e35"
name="AzureDiagnostics">
<filter type=""/>
</add>
</listeners>
</trace>
</system.diagnostics>
- Configuring the Azure Storage Account in the
ServiceConfiguration.cscfg
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="DefaultEndpointsProtocol=https;AccountName=[youracountnamehere];AccountKey=[youraccountkeyhere]/>
</ConfigurationSettings>
<Certificates>
</Certificates>
</Role>
</ServiceConfiguration>
Similar kind of issue is resolved here by re-installing the Windows Azure Tools of VS.
This issue has been addressing since Azure SDK 2.4 even there is no code dependent but need those modules to collect the data for debugging purposes. Try to uninstall and install again, the Azure Development Tools and its included SDK Components in VS: Visual Studio > Tools > Get Tools & Features:

References:
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | SuryasriKamini-MT |

