Skip to content

Commit

Permalink
Use Azure Feed to resolve nuget/crate dependencies (#7373)
Browse files Browse the repository at this point in the history
To comply with security policies, this change updates the nuget (C#) and cargo (Rust) projects in this repo to resolve dependencies through a public Azure feed (which upstreams to nuget.org and crates.io), instead of directly from nuget.org and crates.io.

To support our model of adding/updating packages and to be consistent with the lock files we've enabled for our Rust projects, this change also enables lock files (named packages.lock.json) for our C# projects.

I also found a few of our Rust projects which were not using a lock file, so I added Cargo.lock files to those projects.

All packages have been saved to the feed at the versions given in the various lock files. Whether the pipelines build our code or you build it locally, the Azure feed will be used to download dependency packages. Authentication is not required.

To add/upgrade a package in the feed, you must authenticate with write credentials. For nuget, this is seemless once you install the [credential provider](https://github.com/microsoft/artifacts-credprovider#azure-artifacts-credential-provider). For cargo, the process is not so simple. Ideally, a `cargo login` before `cargo build` would allow you to seamlessly update the feed, but cargo does not currently support optional authentication with fallback to anonymous. In other words, because we allow anonymous access, cargo will not authenticate. Instead, you can use the feed's REST API directly. I updated edgelet/doc/devguide.md with a new section (edgelet/doc/devguide.md#update-a-dependency) that explains how to add/upgrade dependencies in the feed for Rust projects.

To test, I ran the CI Build pipeline (as well as the E2E-Checkin pipeline, plus all the PR check pipelines) and confirmed they all passed.

## Azure IoT Edge PR checklist:
  • Loading branch information
damonbarry authored Sep 27, 2024
1 parent b008102 commit e20dd12
Show file tree
Hide file tree
Showing 84 changed files with 108,594 additions and 35 deletions.
1,422 changes: 1,422 additions & 0 deletions edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Core/packages.lock.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1,435 changes: 1,435 additions & 0 deletions edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Docker/packages.lock.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1,430 changes: 1,430 additions & 0 deletions edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Edgelet/packages.lock.json

Large diffs are not rendered by default.

1,637 changes: 1,637 additions & 0 deletions edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.IoTHub/packages.lock.json

Large diffs are not rendered by default.

1,784 changes: 1,784 additions & 0 deletions edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Service/packages.lock.json

Large diffs are not rendered by default.

1,881 changes: 1,881 additions & 0 deletions edge-agent/test/Microsoft.Azure.Devices.Edge.Agent.Core.Test/packages.lock.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1,629 changes: 1,629 additions & 0 deletions edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Amqp/packages.lock.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1,574 changes: 1,574 additions & 0 deletions edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Core/packages.lock.json

Large diffs are not rendered by default.

1,628 changes: 1,628 additions & 0 deletions edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Http/packages.lock.json

Large diffs are not rendered by default.

1,699 changes: 1,699 additions & 0 deletions edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/packages.lock.json

Large diffs are not rendered by default.

1,888 changes: 1,888 additions & 0 deletions edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Service/packages.lock.json

Large diffs are not rendered by default.

1,380 changes: 1,380 additions & 0 deletions edge-hub/core/src/Microsoft.Azure.Devices.Routing.Core/packages.lock.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2,385 changes: 2,385 additions & 0 deletions edge-hub/core/test/Microsoft.Azure.Devices.Edge.Hub.E2E.Test/packages.lock.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1,831 changes: 1,831 additions & 0 deletions edge-hub/core/test/Microsoft.Azure.Devices.Routing.Core.Test/packages.lock.json

Large diffs are not rendered by default.

935 changes: 935 additions & 0 deletions edge-modules/SimulatedTemperatureSensor/packages.lock.json

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions edge-modules/api-proxy-module/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[registries]
iotedge_PublicPackages = { index = "sparse+https://pkgs.dev.azure.com/iotedge/iotedge/_packaging/iotedge_PublicPackages/Cargo/index/" }

[registry]
global-credential-providers = ["cargo:token", "cargo:libsecret"]

[source.crates-io]
replace-with = "iotedge_PublicPackages"
8 changes: 8 additions & 0 deletions edge-modules/edgehub-proxy/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[registries]
iotedge_PublicPackages = { index = "sparse+https://pkgs.dev.azure.com/iotedge/iotedge/_packaging/iotedge_PublicPackages/Cargo/index/" }

[registry]
global-credential-providers = ["cargo:token", "cargo:libsecret"]

[source.crates-io]
replace-with = "iotedge_PublicPackages"
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

<PropertyGroup>
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

<PropertyGroup>
Expand Down
Loading

0 comments on commit e20dd12

Please sign in to comment.