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.

[BUG] IGenericResource.ApiVersion is always null

See original GitHub issue

Describe the bug When retrieving an IGenericResource instance from genericResources.ListByResourceGroupAsync ApiVersion property is null.

To Reproduce The resource already exists and when showing ARM template in Azure ApiVersion is filled.

var resources = await genericResources.ListByResourceGroupAsync(Config.ResourceGroup);
foreach (var resource in resources)
{
    // resource.ApiVersion is always null
    await resource.Update().WithApiVersion(resource.ApiVersion).WithTags(new DefaultTags()).ApplyAsync();
}

Expected behavior IGenericResource.ApiVersion should be filled with the correct ApiVersion that was used when the resource was created or updated.

Setup (please complete the following information):

  • Microsoft.Azure.Management.Fluent 1.31.0
  • Microsoft.Azure.Management.ResourceManager.Fluent 1.31.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
xseeseeseecommented, Feb 17, 2020

@Rookian For now, you can have simple workaround as below according to the exception you met.

foreach (var resource in resources)
{
    var res = await resourceManager.GenericResources.GetByIdAsync(resource.Id);
    await res.Update().WithApiVersion(res.ApiVersion).WithProperties(res.Properties).WithTags(new DefaultTags()).ApplyAsync();
}

If you don’t want to take extra GET request, please refer how we prepare ApiVersion in SDK And use below code to update the tags

foreach (var resource in resources)
{
    await genericResources.Inner.UpdateByIdAsync(resource.Id, "api-version", new GenericResourceInner
                        {
                            Tags = new DefaultTags()
                        });
}
0reactions
xseeseeseecommented, Feb 20, 2020

@Rookian Great. Thanks for sharing the code snippet, I think it looks good.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Post parameter is always null
I noticed that since the controller action name was prefixed with "Get", Web API treated this as a HTTP GET rather than a...
Read more >
AcountInfo is always null,Acountinfo.username is always null
I used loginWithCustomID then in OnSuccess callback I check for whats in Acountinfo and its null then I use AddUsernamePassword for ...
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