NOTE: This is not your typical null reference error!
The error is a message in the output of the Microsoft Azure Activity Log and is not from code directly in the project that I can debug.
I have a Web Role project that has been publishing to Azure Cloud Services (extended support) instance from Visual Studio. This has been working for many years. Since December 2023 I have not been able to deploy to Azure, this is the Microsoft Azure Activity Log output from the deployment:
3:53:58 PM - Uploading '...\app.publish\test.cspkg' as 'test-2f8682e7.cspkg' to storage account...
3:55:05 PM - Uploading '...\app.publish\ServiceConfiguration.Test.cscfg' as 'ServiceConfiguration.Test-2f8682e7.cscfg' to storage account...
3:55:05 PM - Checking if all the certificates exist in key vault 'https://testeskv.vault.azure.net/'...
3:55:06 PM - Object reference not set to an instance of an object.
VS 2022 Enterprise: v17.8.3
Microsoft Azure Tools: v2.9
If I remove the certificate from the key vault then the deployment stops with the following message:
10:32:45 AM - Uploading '...\app.publish\test.cspkg' as 'FinPalApp.DocumentGenerator.Website.Azure-14a25f38.cspkg' to storage account...
10:33:53 AM - Uploading '...\app.publish\ServiceConfiguration.Test.cscfg' as 'ServiceConfiguration.Test-14a25f38.cscfg' to storage account...
10:33:53 AM - Checking if all the certificates exist in key vault 'https://demodocumentgeneratorkv.vault.azure.net/'...
10:33:53 AM - Error: certificate: ‘Certificate1’ with thumbprint: 27AC9369FAF25207BB2627CEFACCBE4EF9C319B8 for role: Test is not present in the key vault: https://testeskv.vault.azure.net/
This verifies that the List permissions are correctly set on the key vault and that the failure occurs after the certificate check. I suspect the failure is therefore during the network configuration or something else.
I did attempt to increase the log detail, but this didn't provide any further information in the output:
I have also tried disabling remote desktop but that has also not made a difference.
Last year I did experience issues using the staging VIP swap slot that were equally hard to diagnose, similar to this post: Publishing Azure Cloud Services (extended support) from Visual Studio fails with "The language expression property 'slotType' doesn't exist" so I am aware that recent updates to Azure Tools, Visual Studio or the templates and scripts associated with deploying the extended support web roles.
Question: How can I fix this issue or is there a new method to deploy web roles in extended support.
I am actively looking into alternate deployment configurations to remove dependence on this legacy service but I am hoping there is someone else who has experienced this and can offer some assistance.
This issue was reported in a developer community post: Cloud Service (Extended Support) publishing fails with object reference error
The issue was fixed in the release on Feb 13th 2024 — Visual Studio 2022 version 17.9.0 and was available in earlier preview builds.
Updating to the latest solved this issue.
The issue post goes through the technique of debugging these types of issues:
Debug Visual Studio
... launch a seperate instance of Visual Studio, then before publish, use the debug -> Attach to Process menu and attach to the other instance of devenv.exe. Continue the publish and when the Null reference occurs, the debugger should stop at that location
Additional Info
uncheck "Just my code" in Tools->Options->Debugging->General. Also In the "Attach to:" section of the Attach to Process dialog, ensure you have "Automatic:Managed (.NET 4x) code" selected.
The code where the error was raised from:
StackTrace:
at Microsoft.Cct.DiagnosticsConfigurationHelper.FillInConfigXml(String originalPublicConfig, String originalPrivateConfig, BlobServiceClient blobClient, String connectionString, String storageType) in Microsoft.Cct\DiagnosticsConfigurationHelper.cs:line 210
CallStack:
Microsoft.VisualStudio.WindowsAzure.2.9.dll! Microsoft.Cct.DiagnosticsConfigurationHelper.FillInConfigXml(string originalPublicConfig, string originalPrivateConfig, Azure.Storage.Blobs.BlobServiceClient blobClient, string connectionString, string storageType) Line 210 C#
Microsoft.VisualStudio.WindowsAzure.2.9.dll! Microsoft.Cct.DiagnosticsConfigurationHelper.FillStorageKeyIfNeededAsync(string originalPublicConfig, string originalPrivateConfig, string roleName, Microsoft.Cct.ServiceModel.ServiceModelView serviceModel, string serviceConfiguration, Microsoft.VisualStudio.WindowsAzure.ResourceManagement.IAzureSubscriptionContextWrapper context, string fallbackAccountName) Line 171 C#
Microsoft.VisualStudio.WindowsAzure.2.9.dll! Microsoft.Cct.CctProjectConfig.CreateRoleDiagnosticsConfigMappingAsync(Microsoft.VisualStudio.WindowsAzure.ResourceManagement.IAzureSubscriptionContextWrapper context) Line 1244 C#
Microsoft.VisualStudio.WindowsAzure.2.9.dll! Microsoft.Cct.CctProjectConfig.PrepareAzureRMDeployment(Microsoft.VisualStudio.WindowsAzure.ResourceManagement.IAzureSubscriptionContextWrapper context, Microsoft.Cct.ResourceManagement.AzureRMClient armClient, Microsoft.VisualStudio.Azure.Deployment.AzureDeploymentSettings settings, Microsoft.VisualStudio.Azure.Deployment.IAzureCustomDeploymentNotification deployNotification, System.Threading.CancellationToken cancelToken) Line 830 C#