Azure Alert service to auto-update the CMDB has webhook url without credentials in the azure portal


Description

The azure alert configuration from the servicenow instance doesn't support password authentication when creating the webhook url for event based discovery of azure cloud. As part of this change authentication is enabled by providing the username and password in the webhook url in the azure portal under the selected service account and resource group. 

Steps to Reproduce

Go to Azure alert configuration in the instance
Click on New to create a new alert 
Choose the service account, resource group, and the user and provide the password
Validate the alert rule created under the chosen resource group in the Azure portal
Check the webhook URL in the alert rule which will be created with the user and password. 



Workaround

Modified the script include CMPAzureAlertRuleMgr to create the webhook URL with user name and password.
While creating the azure alert rule in the instance, if authentication is required then user id and password have to be provided in the form along with service account and resource group. The webhook url in the azure portal will be created with username and password.

below mentioned code snippet has to be added in the CMPAzureAlertRuleMgr script in function executeCAPI

replace this line of code

var serviceUri = match[1] + match[2].substring(0,match[2].length-1) + path;

with the code below


var serviceUri;
if (gs.nil(password)) {
    serviceUri = match[1] + match[2].substring(0, match[2].length - 1) + path;
} else {
    var credes = userName + ":" + password + "@";
    serviceUri = match[1] + credes + match[2].substring(0, match[2].length - 1) + path;
}



Related Problem: PRB1485817