question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Many Azure.ResourceManager.* sample projects are missing necessary package references

See original GitHub issue

Related to #33969, many MPG sample projects are lacking references they need to actually build, such as Azure.Identity or NUnit. In fact, the fact they are using NUnit means they should be under the tests/ subdirectory (by convention) and have a “.Tests” suffix. See https://github.com/Azure/azure-sdk-for-net/blob/main/doc/DataPlaneCodeGeneration/Create_Samples_Guidance.md. While this mentions data plane, I see no reason management plane shouldn’t be similar.

Several years ago when many of our samples didn’t work or didn’t even compile, several of us creating conventions and tools to make sure they are always run (at least with live tests, if not recorded) and built, and from there we get snippets. This convention is also assumed in many build files. For example, right now these source files will get included anytime IncludeSamples=true IncludeTests=false is passed to builds (effectively; not exact syntax) because the directories are used to determine what are tests, what are samples, etc. Conversely, all these tests that use NUnit won’t get run when running many of these same commands because they are treated like samples and not tests.

As an example, in sdk\iothub\Azure.ResourceManager.IotHub\samples\Generated\Samples\Sample_EventHubConsumerGroupInfoCollection.cs:

using System;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.IotHub;
using Azure.ResourceManager.IotHub.Models;

namespace Azure.ResourceManager.IotHub.Samples
{
    public partial class Sample_EventHubConsumerGroupInfoCollection
    {
        // IotHubResource_ListEventHubConsumerGroups
        [NUnit.Framework.Test]
        [NUnit.Framework.Ignore("Only verifying that the sample builds")]
        public async Task GetAll_IotHubResourceListEventHubConsumerGroups()
// ...

Here’s the project that contains that sample:

<Project Sdk="Microsoft.NET.Sdk">
  <ItemGroup>
    <ProjectReference Include="..\src\Azure.ResourceManager.IotHub.csproj" />
  </ItemGroup>
</Project>

As you can see, there are no PackageReference items to Azure.Identity or NUnit.Framework.

Issue Analytics

  • State:closed
  • Created 7 months ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ArcturusZhangcommented, Feb 17, 2023

Hi @heaths we are able to find and fix some of them in this PR: https://github.com/Azure/azure-sdk-for-net/pull/34283

1reaction
ArcturusZhangcommented, Feb 16, 2023

Well, we might forgot to add the package references for nunit when creating the new project. @dvbb could you take a look and provide some fixes?

Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] Azure.ResourceManager.Resources.dll not added to ...
When we add a NuGet package, all the necessary plumbing is automatic. In this case, the DLL should be referenced by the project...
Read more >
Microsoft Azure Resource Manager client library for .NET
Microsoft Azure Resource Manager is the deployment and management service for Azure. It provides a management layer that enables you to ...
Read more >
Resource not found errors - Azure Resource Manager
For most cases, the reference function isn't needed. The following example references an existing storage account in a different resource group.
Read more >
Quickstart: Troubleshoot ARM template JSON deployments
This quickstart describes how to troubleshoot Azure Resource Manager template (ARM template) JSON deployment errors.
Read more >
This project references NuGet package(s) that are missing ...
This error usually occurs when you change the project directory name or path. edit the .proj file and replace the new directory name...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found