OBLYTECH Logo
OBLYTECH Logo

Azure cloud discovery methods in ServiceNow: setup guide

Azure discovery in ServiceNow is a set of routes, not one feature. Pattern-based cloud discovery, run from a Discovery schedule, is the core route and reads Azure through a service principal. Agent collectors and IP-based discovery fill other gaps. Azure alerts keep configuration items current between scheduled runs, and the subscription and management group setup decides what gets scanned.

Choosing the right Azure discovery method

Each route answers a different question. Pattern-based cloud discovery covers extended virtual CI classes and tag-based service mapping. Service Graph Connectors are a narrower route for basic and generic virtual classes and hardware classes. Agent collectors suit machines that can run the ServiceNow agent, and IP-based horizontal discovery suits server estates reached over the network with OS credentials.

Check requirements before you choose a route:

Requirement Pattern-based cloud Service Graph Connectors Agent, no MID Server Agent, with MID Server IP-based horizontal
MID Server Yes No No Yes Yes
Cloud credential Yes Yes No No No
OS credential No No No No Yes
ServiceNow agent No No Yes Yes No
Azure Log Analytics workspace No Yes No No No

Setting up a cloud discovery schedule

Before you open the schedule form, confirm four things. You need at least one validated MID Server with status Up that can reach the IP ranges you plan to scan, and it must have the Cloud Management capability. You need a service principal in Azure Active Directory with permissions over the target resources, plus matching ServiceNow credentials. The form also expects Discovery Admin Workspace version 1.11.0 or later and the discovery_admin role.

Then the flow runs in this order:

  1. Open Workspaces, Discovery Admin Workspace, Schedules, and select New Discovery.
  2. Choose Cloud-based discovery, name the schedule, and select Azure as the provider.
  3. Pick a MID Server. An existing cluster gives failover and load balancing, while automatic selection chooses an available server when the schedule runs.
  4. Select an existing cloud account, or add one with a name and a subscription ID or management group ID. Those IDs sit in the Azure portal under Subscriptions or Management Groups.
  5. For an Azure management account, choose to discover all subscriptions or specific ones.
  6. Choose the cloud regions to include, and use Refresh cloud regions if the list is empty.
  7. Optionally turn on the server discovery toggle to add an IP-based schedule for virtual machines.
  8. Set the timing: scheduled time, run on demand, run after another series, or a timeout. The event-driven option updates the CMDB from Azure change events.
  9. Select Finish and run to start immediately, or Finish to create the schedule and run it later with Discover Now.

From the Zurich Patch 2 release, you can limit datacenter discovery to subscriptions added since the last discovery.

Linux virtual machines can also be discovered with a service principal and short-lived SSH certificates, which avoids passwords and key pairs on those machines. Create the Azure Service Principal credential first, then an Azure SSH Certificate Credential linked to it. The External Credential Storage plugin must be installed before you create either credential.

Service principals, management groups and subscriptions

An Azure management group holds other management groups and subscriptions. The subscriptions beneath it are called sub-accounts, and discovery records each one as its own service account.

Once the management group credentials pass a test, discovery lists the subscriptions underneath, and you choose which to include. You do not need separate credentials for each sub-account. Selecting the Discover Subscriptions related link again generates a new Discovery status.

A service principal works like a Windows service account for cloud services. Copy three values from Azure into the Azure Service Principal credential: the Directory ID becomes the Tenant ID, the Application ID becomes the Client ID, and the application key becomes the Secret key. The application key is created as a client secret under Certificates & secrets in the Azure portal. Copy the values into a text editor before you transfer them to ServiceNow, and enter the subscription ID or management group ID on the cloud account instead.

The Azure Subscriptions Discovery For Management Group pattern records each subscription as a Cloud Service Account pointing back to its management account. A flag marks management accounts as true and subscription accounts as false. Azure tags are read into the Key Value table and tied to the subscription account.

Keeping the CMDB current with Azure alerts

A scheduled run is a snapshot on a timetable. The Azure alert service can raise an alert for a change in the life-cycle state or configuration of a cloud resource, and ServiceNow can use those alerts to update the CMDB without waiting for the next scheduled discovery. Each alert becomes a record in the Cloud Events table. A Cloud Event Scheduler reads ready events in batches and runs the matching pattern against the affected resource.

The older alert-driven method, which uses legacy authentication, should no longer be used. From Discovery and Service Mapping Patterns version 1.1.0, Azure change processing replaced it for better performance. A secure webhook is the alternative for forwarding alerts.

If you still run the legacy alert-driven method, setup has two easy-to-miss steps. First, turn off authentication on the Cloud Event Scripted REST API, because the Azure Alert service does not support basic authentication. Second, open Discovery, Cloud Alerts, Azure Alert Configurations, and create a record on the Azure tab with a Service Account, a Resource Group, the Activate option, and a user holding the cloud event integration role. The status moves from None to Activated on success. Alert types are managed in the azure_alert_rule table, where each rule has a name, an Action holding the resource operation API path, and an Active flag.

Two operational details matter. Alert configuration keeps sending alerts while the MID Server is down, which fills the ECC queue with errors, so deactivate the rule manually when no MID Server is available. Also, if domain identification fails, an event can stay unassigned and visible across domains. Setting sn_cmp.error_events.default_domain to the sys_id of the service-provider domain limits the visibility of failed events to that administrator.

Datacenters, regions and availability zones

Azure runs datacenters around the world, but your resources sit in some of them. The Azure Datacenter discovery pattern runs first and marks each datacenter as active, meaning it holds resources for the account, or passive, meaning it does not. The remaining patterns then run against active datacenters, a design intended to be more efficient than discovering all datacenters.

From patterns version 1.15.0, the default is active datacenters. Setting the MID Server property mid.cloud.discovery.sonar.discover_all_azure_datacenters to true also records passive ones. Management groups discover all Azure datacenters regardless. From patterns version 1.29.0, Refresh Datacenters displays all regions, so a new resource or a datacenter switching from passive to active does not need a new schedule.

Availability zones need one preparation step. Register the subscription to the AvailabilityZonePeering feature with the Azure CLI, in the Microsoft.Resources namespace, and check its status before running discovery. Let the clean-up job for availability zones finish first, since it removes availability set records the pattern pre-populates.

What the patterns discover

The pattern set covers many Azure services, including application load balancers, Blob storage, Cosmos DB, Express Route circuits, Key Vault keys, Log Analytics workspaces, NAT gateways and route tables. Core infrastructure maps into established CI tables:

Azure component CI table What is recorded
Virtual machine cmdb_ci_vm_instance State shows the power state (On, Off or Error); Memory and CPUs record the allocated capacity
Network and subnet cmdb_ci_network, cmdb_ci_cloud_subnet CIDR holds the network range in CIDR notation, and each subnet records its own CIDR
Network interface cmdb_ci_nic Private IP, MAC address, public DNS name
Public IP address cmdb_ci_cloud_public_ipaddress Public IP address and public DNS name
Storage account cmdb_ci_cloud_storage_account SKU name and provisioning state

Tags are collected into the cmdb_key_value table and related to their CI. Service Mapping’s tag-based discovery then links a configuration item to a logical datacenter, and the datacenter to a cloud service account, using relationships available from the 1.0.68 release on the Store. From patterns version 1.30.2, the Service Account and Logical Datacenter fields can also be populated directly on cloud CIs, with query performance as the stated benefit.

Which Azure permissions and credentials must a buyer confirm before Azure discovery covers the subscriptions and resources they expect?

Confirm three things before you trust the scope: a service principal whose Azure permissions reach every subscription you expect, the management group or subscription IDs the cloud account points at, and the REST permissions each discovery pattern needs. A passing authentication test does not prove that resources are covered.

Start with the list of patterns that will run

Each discovery pattern needs its own REST permissions and works with particular CI classes. Those pattern grants sit on top of the scope the service principal already holds. Export the list of patterns the project will run and check each one against the grants on the service principal. A role that looks broad enough on paper is not evidence that a given pattern can read its resource type.

Confirm the service principal can see every subscription in scope

Subscription visibility depends on the scope and permissions granted to the service principal. Compare the subscriptions discovery returns with the subscription list the buyer keeps. A subscription the credential cannot reach will not appear in the discovered list, so the gap shows only when the two lists are compared.

Ask who owns the client secret and when it expires

Client-secret credentials bring expiry dates and rotation duties with them. Record its expiry date in the same register as the subscription list, and give one named person the job of rotating it before it lapses. An expired secret stops authentication for each subscription that credential covers.

Separate Azure resource coverage from guest coverage

Azure discovery reads what the Azure management layer reports about resources. It does not give complete discovery inside every virtual machine. A buyer who expects software, processes or configuration detail from inside each VM needs a separate guest-level plan with its own route and the credentials that route requires. Treat that as separate scope with separate effort, not as something the Azure schedule covers by default.

Questions to put to the implementer before go-live

  1. Which discovery patterns will run, and which REST permissions does each one need?
  2. Which subscriptions and management groups does the service principal see after the credential test?
  3. Who owns the client secret, and on what date does it expire?
  4. Which resource types fall outside the supported matrix, and how will they be covered?
  5. Is guest-level discovery inside virtual machines in scope, and if so, which route covers it?

What to compare before accepting the scope

Lay three lists side by side: the subscriptions discovery returns, the patterns that will run, and the credential register with owners and expiry dates. Compare them against the estate inventory the buyer already holds. Where the three do not line up, coverage is incomplete, however healthy the schedule looks in the Discovery Admin Workspace.

Frequently asked questions

Do Azure alerts replace a scheduled discovery?

They do different jobs. An alert updates the CMDB for the resource that changed without waiting for the next run. The event-driven option on a schedule works the same way and processes the affected resources. A scheduled run still covers the account on its own timetable.

Can one credential cover the subscriptions under a management group?

Yes. Discovery maps the management group credentials to all subscriptions under it, so one set of credentials covers them all.

Why does my Azure alert configuration keep generating errors?

Alert configuration keeps sending alerts while the MID Server is down, and those alerts fill the ECC queue. Deactivate the Azure alert rule manually until a MID Server is available again.

Are datacenters with no resources in my account discovered?

Not by default. Passive datacenters are skipped unless the mid.cloud.discovery.sonar.discover_all_azure_datacenters property is set to true.