An Azure Function that automatically synchronizes device information from Ninja RMM to Snipe-IT asset management system. This integration runs hourly to maintain an accurate inventory of your IT assets.
- Syncs device information from Ninja RMM to Snipe-IT
- Runs automatically every hour
- Updates existing assets only when changes are detected
- Creates new assets as devices are added to Ninja RMM
Devices are automatically categorized based on their Ninja RMM nodeClass:
- Windows Servers
- Windows Workstations
- VMware Hosts
- Other Hardware
- Serial numbers
- Chassis type
- Virtual machine status
- Node.js 18 or later
- Azure Functions Core Tools
- Azure subscription
- Ninja RMM account with API access
- Snipe-IT installation with API access
-
Clone the repository:
git clone https://github.com/yourusername/ninja-snipeit-sync.git cd ninja-snipeit-sync
-
Install dependencies:
npm install
-
Configure environment variables (see Configuration section)
-
Start the function locally:
npm start
-
Copy
local.settings.template.jsontolocal.settings.json -
Update the following values in
local.settings.json:"NinjaBaseUrl": "https://your-ninja-instance.rmmservice.com", "NinjaAuthEndpoint": "/ws/oauth/token", "NinjaDeviceDetailEndpoint": "/v2/devices-detailed", "NinjaClientID": "your-client-id", "NinjaClientSecret": "your-client-secret", "SnipeBaseURL": "https://your-snipeit-instance/api/v1", "SnipeAPIKey": "your-snipe-it-api-key"
The codebase is organized into three main components:
- Orchestrates the sync process
- Runs on a timer trigger (hourly)
- Validates environment variables
- Initializes services
- Handles OAuth2 authentication
- Retrieves device information
- Filters and normalizes device data
- Processes different device types (servers, workstations, VMware hosts)
- Manages rate limiting (1 second between requests)
- Handles manufacturer creation and caching
- Manages model creation with proper categorization
- Updates assets incrementally
- Implements bulk data loading to minimize API calls
The application includes comprehensive error handling:
- Environment variable validation
- Rate limiting with automatic retries
- Detailed error logging
- Continues processing on individual device failures
- API error recovery
Deploy to Azure Functions using Azure CLI:
az login
az functionapp deployment source config-zip -g <resource-group> -n <app-name> --src <zip-file>
-
Fork the repository
-
Create your feature branch:
git checkout -b feature/AmazingFeature
-
Commit your changes:
git commit -m 'Add some AmazingFeature'
-
Push to the branch:
git push origin feature/AmazingFeature
-
Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For issues, questions, or contributions, please open an issue in the GitHub repository.