Azure Cloud Discovery: CI Location by Datacenter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi all!
We have configured Azure Cloud Discovery with a Service Principal that has access to all the subscriptions. After the Cloud Discovery, we are also running a VM Discovery. We have configured the location of this schedule to be "Azure" so currently all the CIs discovered are assigned to that location. We have also seen that Azure Datacenters (cmdb_ci_azure_datacenter) have a Location field. If we set a location for each Azure Datacenter (e.g. Central US -> Iowa), is there any option to automatically assign to the discovered CIs the location from their datacenter?
Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @davidmoline ,
Yes, this can be achieved, but it is not available out of the box through Azure Cloud Discovery configuration alone.
When Azure resources are discovered, the Location field on the CI is typically populated based on the discovery schedule or default location configuration — which is why all your discovered CIs are currently showing "Azure" as the location.
Since Azure Datacenter CIs (cmdb_ci_azure_datacenter) already hold the actual regional location mapping (e.g., Central US → Iowa), you can leverage that to automatically update discovered CI locations.
The key thing to be aware of is that there is no direct field on the discovered VM/CI pointing to the datacenter. The relationship is stored in the cmdb_rel_ci table, so you will need to traverse that to identify the related Azure Datacenter and read its Location field.
A common approach is:
- Query cmdb_rel_ci to find the relationship between the discovered Azure resource and its Azure Datacenter CI
- Read the Location field from the datacenter CI
- Copy that value back to the discovered CI's Location field
Here's a basic example of the traversal logic:
var rel = new GlideRecord('cmdb_rel_ci'); rel.addQuery('child', current.sys_id); rel.addQuery('type', '<relationship_type_sys_id>'); // e.g., "Hosted On" rel.query(); while (rel.next()) { var datacenter = new GlideRecord('cmdb_ci_azure_datacenter'); if (datacenter.get(rel.parent)) { current.location = datacenter.location; current.update(); } }
This logic can be implemented via a Business Rule, Flow Designer, or Scheduled Script depending on your preference. A Scheduled Script is particularly useful for bulk-updating existing CIs, while a Business Rule handles newly discovered ones going forward.
If you are using IntegrationHub ETL or custom transforms, the same logic can also be applied directly during import/transformation to avoid post-processing updates altogether.
Hope this helps you!
If you find this answer helpful, please mark it as helpful 👍 and accept the solution ✅
Regards,
Tausif Ahmed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @davidmoline
You can use Transform Maps to update the location field during or immediately after discovery.
refer these links if helps:
Steps to ServiceNow Azure Cloud Discovery Configuration: From Credentials to CI Detection
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti