Import from Azure creates duplicate objects in JSM Data Center Assets
Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.
Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles for non-Data Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
In this article, we will discuss a scenario where intermittently duplicate objects are created in Asset during import from Azure. These duplicate objects are created for the Virtual Machine and Subscriptions object_type. In this case, the sync is set to run once a week between 10 PM and 3 AM on Saturday.
Environment
JSM 5.x
Diagnosis
- In this scenario, if two or more objects have the same value for the attribute that is also the object identifier, then those objects are duplicates.
- We can get a list of duplicate objects with the following SQL query for a specific object_type.
- For example, here, duplicates are found for one with the object_type having id 2.
- Also object identifier is attribute id.
SELECT ao."LABEL", COUNT(*) AS count FROM public."AO_8542F1_IFJ_OBJ" ao where ao."OBJECT_TYPE_ID" = '2' GROUP BY ao."LABEL" having ao."count" > 1 ;
- Output of Sql query would be like
- Objects in Assets look like the following screenshot. We can also get OBJECT_TYPE_ID from this screenshot.
Solution
- The user would have to configure an attribute to be unique for a specific object_type. For example, in the screenshot, ID is that attribute, which is set to Unique. These modifications will be effective for future imports.
- The same configuration would apply to the attribute(which is also an object identifier) of the Virtual Machine and Subscriptions object_type.
- Existing Duplicate objects would have to deleted manually or if possible delete all objects and then run complete schema synchronisation so that no new duplicates are created. Duplicate objects are the one which are created recently or which has newer Key. It is advisable to first attempt this process in a non-production or staging environment.