Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public async Task CreateEnrollmentGroupAsync()
Attestation attestation = new SymmetricKeyAttestation(null, null); // let the service generate keys
var group = new EnrollmentGroup(s_enrollmentGroupId, attestation);

// Optionally, set credentialPolicyName if you are using a certificate management service
// group.CredentialPolicyName = "your-azure-device-registry-credential-policy-name";

group = await _provisioningServiceClient.CreateOrUpdateEnrollmentGroupAsync(group);
Console.WriteLine($"Created {group.EnrollmentGroupId}: {JsonConvert.SerializeObject(group)}");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Devices.Provisioning.Service" Version="1.18.4" />
<ProjectReference Include="..\..\..\src\Microsoft.Azure.Devices.Provisioning.Service.csproj" />
<PackageReference Include="CommandLineParser" Version="2.9.1" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ public async Task CreateIndividualEnrollmentTpmAsync()
["Brand"] = "Contoso",
["Model"] = "SSC4",
["Color"] = "White",
})
}),
// Optionally, set credentialPolicyName if you are using a certificate management service
// CredentialPolicyName = "your-azure-device-registry-credential-policy-name"
};

Console.WriteLine("Adding new individualEnrollment...");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="Microsoft.Azure.Devices.Provisioning.Service" Version="1.18.4" />
<ProjectReference Include="..\..\..\src\Microsoft.Azure.Devices.Provisioning.Service.csproj" />
</ItemGroup>

</Project>
6 changes: 6 additions & 0 deletions provisioning/service/src/Config/EnrollmentGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,12 @@ public Attestation Attestation
[JsonProperty(PropertyName = "iotHubHostName", DefaultValueHandling = DefaultValueHandling.Ignore)]
public string IotHubHostName { get; set; }

/// <summary>
/// Linked Azure Device Registry credential policy name (optional).
/// </summary>
[JsonProperty(PropertyName = "credentialPolicyName", DefaultValueHandling = DefaultValueHandling.Ignore)]
public string CredentialPolicyName { get; set; }

/// <summary>
/// Initial twin state.
/// </summary>
Expand Down
6 changes: 6 additions & 0 deletions provisioning/service/src/Config/IndividualEnrollment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,12 @@ internal IndividualEnrollment(
[JsonProperty(PropertyName = "deviceId", DefaultValueHandling = DefaultValueHandling.Ignore)]
public string DeviceId { get; set; }

/// <summary>
/// Linked Azure Device Registry credential policy name (optional).
/// </summary>
[JsonProperty(PropertyName = "credentialPolicyName", DefaultValueHandling = DefaultValueHandling.Ignore)]
public string CredentialPolicyName { get; set; }

/// <summary>
/// Current registration state.
/// </summary>
Expand Down
3 changes: 3 additions & 0 deletions provisioning/service/tests/Config/EnrollmentGroupTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class EnrollmentGroupTests
private const string SampleLastUpdatedDateTimeUTCString = "2017-11-14T12:34:18.321Z";
private DateTime SampleLastUpdatedDateTimeUTC = new DateTime(2017, 11, 14, 12, 34, 18, 321, DateTimeKind.Utc);
private const string SampleEtag = "00000000-0000-0000-0000-00000000000";
private const string SampleCredentialPolicyName = "testCredentialPolicyName";
private const string SamplePublicKeyCertificateString =
"-----BEGIN CERTIFICATE-----\n" +
"MIIBiDCCAS2gAwIBAgIFWks8LR4wCgYIKoZIzj0EAwIwNjEUMBIGA1UEAwwLcmlv\n" +
Expand Down Expand Up @@ -63,6 +64,7 @@ public class EnrollmentGroupTests
" }\n" +
" },\n" +
" \"iotHubHostName\":\"" + SampleIotHubHostName + "\",\n" +
" \"credentialPolicyName\":\"" + SampleCredentialPolicyName + "\",\n" +
" \"initialTwin\":{\n" +
" \"tags\":{\n" +
" \"tag1\":\"val1\",\n" +
Expand Down Expand Up @@ -131,6 +133,7 @@ public void EnrollmentGroupConstructorJSONSucceed()
Assert.AreEqual(SampleEnrollmentGroupId, enrollmentGroup.EnrollmentGroupId);
Assert.IsTrue(enrollmentGroup.Attestation is X509Attestation);
Assert.AreEqual(SampleIotHubHostName, enrollmentGroup.IotHubHostName);
Assert.AreEqual(SampleCredentialPolicyName, enrollmentGroup.CredentialPolicyName);
Assert.IsNotNull(enrollmentGroup.InitialTwinState);
Assert.AreEqual(SampleProvisioningStatus, enrollmentGroup.ProvisioningStatus);
Assert.AreEqual(SampleCreateDateTimeUTC, enrollmentGroup.CreatedDateTimeUtc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class IndividualEnrollmentTests
private const string SampleLastUpdatedDateTimeUTCString = "2017-11-14T12:34:18.321Z";
private DateTime SampleLastUpdatedDateTimeUTC = new DateTime(2017, 11, 14, 12, 34, 18, 321, DateTimeKind.Utc);
private const string SampleEtag = "00000000-0000-0000-0000-00000000000";
private const string SampleCredentialPolicyName = "testCredentialPolicyName";
private DeviceCapabilities SampleEdgeCapabilityTrue = new DeviceCapabilities { IotEdge = true };
private DeviceCapabilities SampleEdgeCapabilityFalse = new DeviceCapabilities { IotEdge = false };
private const string SampleEndorsementKey =
Expand Down Expand Up @@ -69,6 +70,7 @@ public class IndividualEnrollmentTests
" },\n" +
" \"iotHubHostName\":\"" + SampleIotHubHostName + "\",\n" +
" \"deviceId\":\"" + SampleDeviceId + "\",\n" +
" \"credentialPolicyName\":\"" + SampleCredentialPolicyName + "\",\n" +
" \"initialTwin\":{\n" +
" \"tags\":{\n" +
" \"tag1\":\"val1\",\n" +
Expand Down Expand Up @@ -266,6 +268,7 @@ public void IndividualEnrollmentConstructorWithoutCapabilitiesJSONSucceed()
Assert.IsTrue(individualEnrollment.Attestation is X509Attestation);
Assert.AreEqual(SampleDeviceId, individualEnrollment.DeviceId);
Assert.AreEqual(SampleIotHubHostName, individualEnrollment.IotHubHostName);
Assert.AreEqual(SampleCredentialPolicyName, individualEnrollment.CredentialPolicyName);
Assert.IsNotNull(individualEnrollment.InitialTwinState);
Assert.AreEqual(SampleProvisioningStatus, individualEnrollment.ProvisioningStatus);
Assert.AreEqual(SampleCreateDateTimeUTC, individualEnrollment.CreatedDateTimeUtc);
Expand Down