Over the weekend, I found an issue with the Azure portal when I tried to enable the logging for the NSG(network Security group) in an Azure Subscription. The logging from the portal can be enabled by going to the NSG and then in the settings blade, click Diagnostics and then in the diagnostics pane, next to Status , click on the ON button. As soon as you do this, you will run into an error similar to the below.
This error happens when the Microsoft Insights is unable to register with the resource and will not show any data. To work around this issue, a PowerShell cmdlet needs to be executed to enable Microsoft Insights with this resource. I have also noted that this is not isolated to the NSG diagnostics only. Please note that Azure PowerShell module is required to be installed on the local computer before the cmdlets can be run. To install the Azure PowerShell, please follow the link below and download the WebPI(web platform installer) for the azure PowerShell. The link to install the PowerShell module for Azure is below.
After the installation of the cmdlet, please run the following from the PowerShell console:
#Login to the Azure subscriptions
#Get the list of available subscriptions
#Select the subscription which would need the diagnostics to be enabled, change the subscription name to the selected subscription
Select-AzureRmSubscription -SubscriptionName ‘NameofSub’
#Register the Microsoft Insights with the diagnostics
Register-AzureRmResourceProvider -ProviderNamespace Microsoft.Insights
After running the cmdlet, the logging capabilities will be visible in the portal and can be enabled for the NSG. The option to enable the diagnostics is visible on the portal as shown below.
Hope you enjoyed this quick fix. Till next time. 🙂