How can i trigger a cloud discovery through scripts or in flow

subin ps1
Tera Contributor

Hi ,

 

We are creating Azure resource groups using a catalog item , after sending the data we wanted to run  a cloud discovery on the flow , how can we achieve this .

 

Thanks in Advance..

4 REPLIES 4

Manmohan K
Tera Sage

Hi @subin ps1 ,

 

You can create a script step in Flow designer

 

ManmohanK_1-1685367873096.png

 

and use below code to run discovery 

 

 

function RunMyDiscoverNow() {

//Enter the IP Adresses in the Array IPAdresses, and comma seperate
//Example: "x.x.x.1, x.x.x.2, x.x.x.3"

var IPAdresses = "10.200.218.27, 10.200.218.99, 10.200.218.191";

var iparray = IPAdresses.split(",");

for (var i=0; i < iparray.length; i++) {
  var ipaddr = iparray[i]
  
  //Ensure that a valid MID server name is used as the 
  //2nd parameter to d.discoveryFromIP
  
  var d = new Discovery();
  var statusID = d.discoveryFromIP(ipaddr,'MIDSERVER1');
  gs.print("This is the address that was scanned " +ipaddr);
  } 
}

RunMyDiscoverNow();

 

Manmohan K
Tera Sage

Appli
Mega Sage
Mega Sage

Hi, try to create a custom action that calls the script invoking a specific schedule, created before. 

Link to API.

 

Hope it helps

Amit Gujarathi
Giga Sage
Giga Sage

HI @subin ps1 ,
I trust you are doing great.

To achieve running a cloud discovery after creating Azure resource groups using a catalog item in ServiceNow, you can follow these steps:

  1. Create a catalog item: Set up a catalog item in ServiceNow to allow users to request the creation of Azure resource groups. This item should capture all the necessary information for the creation process.

  2. Create a workflow: Build a workflow in ServiceNow to handle the creation of Azure resource groups. This workflow should include the necessary activities to interact with the Azure platform, such as using Azure APIs or Azure PowerShell modules.

  3. Integration with Azure: Configure ServiceNow to integrate with Azure. This integration involves setting up authentication credentials, such as Azure Active Directory (AAD) service principal, to establish a connection between ServiceNow and Azure.

  4. Azure resource group creation: In the workflow, write the necessary code or use ServiceNow's built-in activities to invoke Azure APIs and create the resource groups. Ensure that you capture the relevant data from the catalog item and pass it to the Azure API calls.

  5. Trigger cloud discovery: After successfully creating the resource groups, you can trigger the cloud discovery process to populate the ServiceNow CMDB (Configuration Management Database) with information about the newly created Azure resources.


Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi