it('sends a request to the server to update Config.value on ' + testArgs.descriptionFragment, function(done) {
     var jobId = uuid.v4();
     var client = JobClient.fromConnectionString(hubConnectionString);
     client.scheduleDeviceConfigurationUpdate(jobId, testArgs.ids, 'value', function(err, response) {
         if (err) done(err);
         else {
             assert.equal(response.jobId, jobId);
             assert.equal(response.type, 'updateDeviceConfiguration');
             assert.notInclude(['failed', 'cancelled'], response.status);
             done();
         }
     });
 });
            JSON.stringify(output) :
            '\nFeedback message\n' + prettyjson.render(output);

          console.log(rendered);

          if (!forever && --messageCount === 0) process.exit(0);
        });
      });
    }
  });
}
else if (command === 'get-job') {
  if (!arg1) inputError('No job ID given');
  
  var jobClient = connString ? 
    JobClient.fromConnectionString(connString) :
    JobClient.fromSharedAccessSignature(sas.toString());
    
    jobClient.getJob(arg1, function (err, job) {
      if (err) serviceError(err);
      printResult(job);
    });
}
else if (command === 'read') {
  if (!arg1) inputError('No device IDs given');
  if (!arg2) inputError('No device properties given');

  var jobId = uuid.v4();
  var devices = arrayFromCommaDelimitedList(arg1);
  var properties = arrayFromCommaDelimitedList(arg2);
  var jobClient = connString ? 
Beispiel #3
0
// 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 uuid = require('uuid');
var JobClient = require('azure-iothub').JobClient;

var connectionString = '<IoT Hub Connection String>';
var deviceArray = ['<Device Id>', '<Device Id>'];
var startTime = new Date();
var maxExecutionTimeInSeconds =  3600;

var jobClient = JobClient.fromConnectionString(connectionString);

// Schedule a device method call.
var methodParams = {
  methodName: 'methodName',
  payload: null,
  timeoutInSeconds: 42
};

var methodJobId = uuid.v4();
console.log('scheduling Device Method job with id: ' + methodJobId);
jobClient.scheduleDeviceMethod(methodJobId,
                               deviceArray,
                               methodParams,
                               startTime,
                               maxExecutionTimeInSeconds,
                               function(err) {
  if (err) {
// 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 iothub = require('azure-iothub');

// The connection string used here must have 'registry read' permissions to be able to use the query APIs.
var connectionString = '[IoT Hub Connection String]';

// The JobClient objects has method to schedule jobs, and query existing jobs and job history.
var jobClient = iothub.JobClient.fromConnectionString(connectionString);

// A query with all parameters set to null is an equivalent of SELECT *
var jobQuery = {
  project: null,
  aggregate: null,
  filter: null,
  sort: null
};

// This aggregate query will count the number of jobs for each job type.
var aggregateQuery = {
  project: null,
  aggregate: {
    keys: [{
      name: 'Type',
      type: 'default'
    }],
    properties: [{
      operator: 'count',