Skip to content

Commit

Permalink
Merged PR 915794: Update DeviceSDk to 1.17.0 and ServiceSDK to 1.16.0
Browse files Browse the repository at this point in the history
Updated nugget packages
Fix breaking change to ConfigurationContent
  • Loading branch information
ancaantochi committed Jun 22, 2018
1 parent 24bb823 commit 237e352
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Devices" Version="1.16.0-preview-005" />
<PackageReference Include="Microsoft.Azure.Devices.Client" Version="1.17.0-preview-012" />
<PackageReference Include="Microsoft.Azure.Devices" Version="1.16.0" />
<PackageReference Include="Microsoft.Azure.Devices.Client" Version="1.17.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Amqp" Version="2.2.0" />
<PackageReference Include="Microsoft.Azure.Devices" Version="1.16.0-preview-003" />
<PackageReference Include="Microsoft.Azure.Devices" Version="1.16.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\edge-util\src\Microsoft.Azure.Devices.Edge.Util\Microsoft.Azure.Devices.Edge.Util.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Devices" Version="1.16.0-preview-003" />
<PackageReference Include="Microsoft.Azure.Devices" Version="1.16.0" />
<PackageReference Include="Stateless" Version="4.0.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="11.1.0" />
<PackageReference Include="Microsoft.Azure.Devices.Client" Version="1.17.0-preview-012" />
<PackageReference Include="Microsoft.Azure.Devices.Client" Version="1.17.0" />
<PackageReference Include="System.ValueTuple" Version="4.4.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.WebSockets" Version="2.1.1" />
<PackageReference Include="Microsoft.Azure.Devices" Version="1.16.0-preview-003" />
<PackageReference Include="Microsoft.Azure.Devices" Version="1.16.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,6 @@ Task ConfigUpdatedCallback(EdgeHubConfig updatedConfig)

async Task SetDesiredProperties(RegistryManager registryManager, string edgeDeviceId)
{
var cc = new ConfigurationContent() { ModuleContent = new Dictionary<string, TwinContent>() };
var twinContent = new TwinContent();
cc.ModuleContent["$edgeHub"] = twinContent;

var desiredProperties = new
{
schemaVersion = "1.0",
Expand All @@ -299,18 +295,24 @@ async Task SetDesiredProperties(RegistryManager registryManager, string edgeDevi
timeToLiveSecs = 20
}
};
string patch = JsonConvert.SerializeObject(desiredProperties);

twinContent.TargetContent = new TwinCollection(patch);
var cc = new ConfigurationContent
{
ModulesContent = new Dictionary<string, IDictionary<string, object>>
{
["$edgeAgent"] = new Dictionary<string, object>
{
["properties.desired"] = desiredProperties

}
}
};

await registryManager.ApplyConfigurationContentOnDeviceAsync(edgeDeviceId, cc);
}

async Task UpdateDesiredProperties(RegistryManager registryManager, string edgeDeviceId)
{
var cc = new ConfigurationContent() { ModuleContent = new Dictionary<string, TwinContent>() };
var twinContent = new TwinContent();
cc.ModuleContent["$edgeHub"] = twinContent;

var desiredProperties = new
{
schemaVersion = "1.0",
Expand All @@ -327,8 +329,18 @@ async Task UpdateDesiredProperties(RegistryManager registryManager, string edgeD
}
};

string patch = JsonConvert.SerializeObject(desiredProperties);
twinContent.TargetContent = new TwinCollection(patch);
var cc = new ConfigurationContent
{
ModulesContent = new Dictionary<string, IDictionary<string, object>>
{
["$edgeAgent"] = new Dictionary<string, object>
{
["properties.desired"] = desiredProperties

}
}
};

await registryManager.ApplyConfigurationContentOnDeviceAsync(edgeDeviceId, cc);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Devices.Client" Version="1.17.0-preview-012" />
<PackageReference Include="Microsoft.Azure.Devices.Client" Version="1.17.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="2.1.1" />
Expand Down
2 changes: 1 addition & 1 deletion edge-modules/TemperatureFilter/TemperatureFilter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Devices.Client" Version="1.17.0-preview-012" />
<PackageReference Include="Microsoft.Azure.Devices.Client" Version="1.17.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.1.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Devices.Client" Version="1.17.0-preview-012" />
<PackageReference Include="Microsoft.Azure.Devices.Client" Version="1.17.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions" Version="3.0.0-beta3" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion smoke/IotEdgeQuickstart/IotEdgeQuickstart.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<ItemGroup>
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="2.2.0-*" />
<PackageReference Include="Microsoft.Azure.Devices" Version="1.16.0-preview-003" />
<PackageReference Include="Microsoft.Azure.Devices" Version="1.16.0" />
<PackageReference Include="Microsoft.Azure.EventHubs" Version="1.1.0" />
<PackageReference Include="Microsoft.CodeCoverage" Version="1.0.3" />
<PackageReference Include="RunProcessAsTask" Version="1.2.1" />
Expand Down
20 changes: 18 additions & 2 deletions smoke/IotEdgeQuickstart/details/Details.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace IotEdgeQuickstart.Details
{
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -12,6 +13,7 @@ namespace IotEdgeQuickstart.Details
using Microsoft.Azure.Devices.Shared;
using Microsoft.Azure.EventHubs;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

public class Details
{
Expand Down Expand Up @@ -224,7 +226,21 @@ protected Task RemoveTempSensorFromEdgeDevice()
(string deployJson, string[] _) = this.DeploymentJson();

var config = JsonConvert.DeserializeObject<ConfigurationContent>(deployJson);
config.ModuleContent["$edgeAgent"].TargetContent["modules"] = new { };
JObject desired = JObject.FromObject(config.ModulesContent["$edgeAgent"]["properties.desired"]);
if (desired.TryGetValue("modules", out JToken modules))
{
IList<JToken> removeList = new List<JToken>();
foreach (JToken module in modules.Children())
{
removeList.Add(module);
}

foreach (JToken module in removeList)
{
module.Remove();
}
}
config.ModulesContent["$edgeAgent"]["properties.desired"] = desired;

return this.context.RegistryManager.ApplyConfigurationContentOnDeviceAsync(this.context.Device.Id, config);
}
Expand Down Expand Up @@ -340,7 +356,7 @@ string BuildImageName(string name)

const string DeployJson = @"
{
""moduleContent"": {
""modulesContent"": {
""$edgeAgent"": {
""properties.desired"": {
""schemaVersion"": ""1.0"",
Expand Down

0 comments on commit 237e352

Please sign in to comment.