IExportService
The export interface provides paired methods for each resource type:ExportXxxAsync(single, outputPath, migrationTable)- Export single resourceExportXxxsAsync(collection, outputPath)- Export multiple resources (creates migration table)
Service Lifetime
IExportService is registered as transient (new instance per use).
ServiceCollectionExtensions.cs:61 for registration.
Export Format
Each resource type exports to its own subfolder with JSON files named by display name.Directory Structure
Folder Names by Resource Type
| Resource Type | Folder Name |
|---|---|
| Device configurations | DeviceConfigurations |
| Compliance policies | CompliancePolicies |
| Applications | Applications |
| Endpoint security intents | EndpointSecurity |
| Administrative templates | AdministrativeTemplates |
| Settings catalog | SettingsCatalog |
| Enrollment configurations | EnrollmentConfigurations |
| App protection policies | AppProtectionPolicies |
| PowerShell scripts | DeviceManagementScripts |
| Shell scripts (macOS) | DeviceShellScripts |
| Proactive remediations | DeviceHealthScripts |
| Autopilot profiles | AutopilotProfiles |
| Terms and Conditions | TermsAndConditions |
| Scope tags | ScopeTags |
| Role definitions | RoleDefinitions |
ExportService.cs:21 for folder path logic.
File Naming
Files are named{DisplayName}.json with invalid filename characters replaced by underscores:
ExportService.cs:69 for sanitization logic.
Migration Table
The migration table tracks original IDs and remapped IDs for cross-tenant import.Structure
MigrationTable Model
MigrationTable.cs:6 for the complete model.
Export Methods
Device Configurations
ExportService.cs:15 for implementation.
Compliance Policies
ExportService.cs:89 and CompliancePolicyExport.cs for details.
Settings Catalog Policies
ExportService.cs:557 and SettingsCatalogExport.cs for details.
PowerShell Scripts
ExportService.cs:1011 for implementation.
Import Service
IImportService
The import service reads exported JSON files and creates resources in the destination tenant with ID remapping.IImportService.cs:6 for the complete interface.
Import Workflow
1. Read migration tableID Remapping
During import, the service:- Strips read-only properties (
Id,CreatedDateTime,LastModifiedDateTime) - Remaps group assignment IDs using the migration table
- Creates the resource in the destination tenant
- Captures the new ID and updates the migration table
ImportService.cs for remapping logic.
Export All Resources
Example of exporting all supported resource types:Use Cases
Backup
Export all configurations to a timestamped folder for disaster recovery:Tenant Migration
Move configurations from one tenant to another:- Export from source tenant
- Create matching groups in destination tenant (manually or via script)
- Update migration table with group ID mappings
- Import to destination tenant with ID remapping
Configuration Templates
Create reusable configuration templates:- Build “gold” configurations in a lab tenant
- Export to version control (Git)
- Import to production tenants as needed
Disaster Recovery
Restore deleted policies from backup:- Keep periodic exports
- On accidental deletion, read from backup
- Import to recreate the deleted resource
Limitations
Not Exported
- Application binaries: Win32 app
.intunewinpackages are not exported (only metadata) - Certificates: Certificate files embedded in profiles are not extracted
- Assignment filters: Filter definitions must be recreated manually
- Conditional Access policies: Read-only (not exported to prevent lockout)
Manual Steps After Import
- Group creation (groups are referenced by ID but not created)
- Certificate upload (for SCEP/VPN profiles)
- Win32 app re-upload (binary content)
- Assignment filter recreation
Next Steps
API Overview
Return to API architecture overview
Graph Services
Explore Graph API service interfaces