-
Notifications
You must be signed in to change notification settings - Fork 226
/
create_enrollment_group.js
41 lines (35 loc) · 1.3 KB
/
create_enrollment_group.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
'use strict';
var fs = require('fs');
var provisioningServiceClient = require('azure-iot-provisioning-service').ProvisioningServiceClient;
var serviceClient = provisioningServiceClient.fromConnectionString(process.argv[2]);
var enrollment = {
enrollmentGroupId: 'first',
attestation: {
type: 'x509',
x509: {
signingCertificates: {
primary: {
certificate: fs.readFileSync(process.argv[3], 'utf-8').toString()
}
}
}
},
provisioningStatus: 'disabled'
};
serviceClient.createOrUpdateEnrollmentGroup(enrollment, function(err, enrollmentResponse) {
if (err) {
console.log('error creating the group enrollment: ' + err);
} else {
console.log("enrollment record returned: " + JSON.stringify(enrollmentResponse, null, 2));
enrollmentResponse.provisioningStatus = 'enabled';
serviceClient.createOrUpdateEnrollmentGroup(enrollmentResponse, function(err, enrollmentResponse) {
if (err) {
console.log('error updating the group enrollment: ' + err);
} else {
console.log("updated enrollment record returned: " + JSON.stringify(enrollmentResponse, null, 2));
}
});
}
});