Search in sources :

Example 1 with ManagedIdentity

use of com.microsoft.azure.sdk.iot.deps.serializer.ManagedIdentity in project azure-iot-sdk-java by Azure.

the class DeviceManagerImportExportWithIdentitySample method ExportDevices.

public static void ExportDevices() throws IOException, IotHubException, InterruptedException {
    RegistryManager registryManager = RegistryManager.createFromConnectionString(sourceHubConnectionString);
    // If StorageAuthenticationType is set to IdentityBased and userAssignedIdentity property is
    // not null, the jobs will use user defined managed identity. If the IoT hub is not
    // configured with the user defined managed identity specified in userAssignedIdentity,
    // the job will fail.
    // If StorageAuthenticationType is set to IdentityBased the userAssignedIdentity property is
    // null, the jobs will use system defined identity. If the IoT hub is not configured with the
    // user defined managed identity, the job will fail.
    // If StorageAuthenticationType is set to IdentityBased and neither user defined nor system defined
    // managed identities are configured on the hub, the job will fail.
    ManagedIdentity identity = new ManagedIdentity();
    identity.setUserAssignedIdentity(userDefinedManagedIdentityResourceId);
    JobProperties jobProperties = JobProperties.createForExportJob(blobContainerUri, false, StorageAuthenticationType.IDENTITY, identity);
    JobProperties exportJob = registryManager.exportDevices(jobProperties);
    while (true) {
        exportJob = registryManager.getJob(exportJob.getJobId());
        if (exportJob.getStatus() == JobProperties.JobStatus.COMPLETED) {
            break;
        }
        Thread.sleep(500);
    }
    registryManager.close();
}
Also used : JobProperties(com.microsoft.azure.sdk.iot.service.JobProperties) RegistryManager(com.microsoft.azure.sdk.iot.service.RegistryManager) ManagedIdentity(com.microsoft.azure.sdk.iot.deps.serializer.ManagedIdentity)

Example 2 with ManagedIdentity

use of com.microsoft.azure.sdk.iot.deps.serializer.ManagedIdentity in project azure-iot-sdk-java by Azure.

the class DeviceManagerImportExportWithIdentitySample method ImportDevices.

public static void ImportDevices() throws IOException, IotHubException, InterruptedException {
    RegistryManager registryManager = RegistryManager.createFromConnectionString(destinationHubConnectionString);
    // If StorageAuthenticationType is set to IdentityBased and userAssignedIdentity property is
    // not null, the jobs will use user defined managed identity. If the IoT hub is not
    // configured with the user defined managed identity specified in userAssignedIdentity,
    // the job will fail.
    // If StorageAuthenticationType is set to IdentityBased the userAssignedIdentity property is
    // null, the jobs will use system defined identity. If the IoT hub is not configured with the
    // user defined managed identity, the job will fail.
    // If StorageAuthenticationType is set to IdentityBased and neither user defined nor system defined
    // managed identities are configured on the hub, the job will fail.
    ManagedIdentity identity = new ManagedIdentity();
    identity.setUserAssignedIdentity(userDefinedManagedIdentityResourceId);
    JobProperties jobProperties = JobProperties.createForImportJob(blobContainerUri, blobContainerUri, StorageAuthenticationType.IDENTITY, identity);
    JobProperties exportJob = registryManager.importDevices(jobProperties);
    while (true) {
        exportJob = registryManager.getJob(exportJob.getJobId());
        if (exportJob.getStatus() == JobProperties.JobStatus.COMPLETED) {
            break;
        }
        Thread.sleep(500);
    }
    registryManager.close();
}
Also used : JobProperties(com.microsoft.azure.sdk.iot.service.JobProperties) RegistryManager(com.microsoft.azure.sdk.iot.service.RegistryManager) ManagedIdentity(com.microsoft.azure.sdk.iot.deps.serializer.ManagedIdentity)

Aggregations

ManagedIdentity (com.microsoft.azure.sdk.iot.deps.serializer.ManagedIdentity)2 JobProperties (com.microsoft.azure.sdk.iot.service.JobProperties)2 RegistryManager (com.microsoft.azure.sdk.iot.service.RegistryManager)2