azure-sdk-for-net: [BUG] The resource type 'locations/databaseOperationResults' could not be found in the namespace 'Microsoft.Sql' for api version '2022-09-01'

Library name and version

Azure.ResourceManager 1.8.1 or 1.8.0

Describe the bug

When adding a resource tag to a SQL Azure database I am getting an exception about an unknown API version. The tag is actually written because just the wait for the operation to complete fails. Nonetheless the exception is an exception interrupting the program flow.

Expected behavior

The resource tag is written without exception.

Actual behavior

Azure.RequestFailedException: "The resource type ‘locations/databaseOperationResults’ could not be found in the namespace ‘Microsoft.Sql’ for api version ‘2022-09-01’. The supported api-versions are ‘2017-03-01-preview,2017-10-01-preview,2018-06-01-preview,2019-06-01-preview,2020-02-02-preview,2020-08-01-preview,2020-11-01-preview,2021-02-01-preview,2021-05-01-preview,2021-08-01-preview,2021-11-01,2021-11-01-preview,2022-02-01-preview,2022-05-01-preview,2022-08-01-preview,2022-11-01-preview,2023-02-01-preview,2023-05-01-preview’. Status: 404 (Not Found) ErrorCode: InvalidResourceType

Content: {“error”:{“code”:“InvalidResourceType”,“message”:“The resource type ‘locations/databaseOperationResults’ could not be found in the namespace ‘Microsoft.Sql’ for api version ‘2022-09-01’. The supported api-versions are ‘2017-03-01-preview,2017-10-01-preview,2018-06-01-preview,2019-06-01-preview,2020-02-02-preview,2020-08-01-preview,2020-11-01-preview,2021-02-01-preview,2021-05-01-preview,2021-08-01-preview,2021-11-01,2021-11-01-preview,2022-02-01-preview,2022-05-01-preview,2022-08-01-preview,2022-11-01-preview,2023-02-01-preview,2023-05-01-preview’.”}}

Headers: Cache-Control: no-cache Pragma: no-cache x-ms-failure-cause: REDACTED x-ms-ratelimit-remaining-subscription-reads: REDACTED x-ms-request-id: cb1bf479-fee4-43fe-9bc6-b601404ce2e9 x-ms-correlation-request-id: REDACTED x-ms-routing-request-id: REDACTED Strict-Transport-Security: REDACTED X-Content-Type-Options: REDACTED Date: Tue, 07 Nov 2023 12:24:10 GMT Content-Type: application/json; charset=utf-8 Expires: -1 Content-Length: 557 "

Reproduction Steps

Create a new Azure subscription. Add a SQL Azure elastic pool with service tier = Standard, 100 eDTUs and location “West Europe”. Add a SQL Azure database the elastic pool with 10GB max storage. (not sure if the elastic pool is required, my database is part of an elastic pool)

Create a new C# command line application. Add nugets Azure.Identity-1.10.3 and Azure.ResourceManager-1.8.1.

Setup authentication for Azure.Identity.

Use the following code in the command line application replacing the placeholders with the value from your subscription and database.

using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;

var armClient = new ArmClient(new DefaultAzureCredential(), "<subscription_id>");
var sqlDatabaseResourceIdentifier = new ResourceIdentifier("/subscriptions/<subscription_id>/resourceGroups/<resource_group_name>/providers/Microsoft.Sql/servers/<sql_server_name>/databases/<sql_database_name>");
var databaseResource = armClient.GetGenericResource(sqlDatabaseResourceIdentifier);
databaseResource = await databaseResource.GetAsync();
await databaseResource.AddTagAsync("TestKey", "TestValue");

Run the application. Observe the exception thrown by the last line.

Environment

C:\>dotnet --info
.NET SDK:
 Version:   7.0.403
 Commit:    142776d834

Runtime:
 OS Name:     Windows
 OS Version:  10.0.19045
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\7.0.403\

Host:
  Version:      7.0.13
  Architecture: x64
  Commit:       3f73a2f186

Visual Studio Version 17.7.6

About this issue

  • Original URL
  • State: open
  • Created 8 months ago
  • Reactions: 1
  • Comments: 18 (6 by maintainers)

Most upvoted comments

@archerzz Thank you for the workaround. The following code works for me.

using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;

var armClient = new ArmClient(new DefaultAzureCredential(), "<subscription_id>");
var sqlDatabaseResourceIdentifier = new ResourceIdentifier("/subscriptions/<subscription_id>/resourceGroups/<resource_group_name>/providers/Microsoft.Sql/servers/<sql_server_name>/databases/<sql_database_name>");
var databaseResource = armClient.GetGenericResource(sqlDatabaseResourceIdentifier);
databaseResource = await databaseResource.GetAsync();
databaseResource.Data.Tags["TestKey"] = "TestValue";
databaseResource.Update(WaitUntil.Completed, databaseResource.Data);

Hi @m-redding,

I also have a CX report this issue, I could reproduce this as well.

az tag update --resource-id /subscriptions/1s9d4-bc2a-0000-0000-4cb19853gh6/resourceGroups/RG/providers/Microsoft.Sql/servers/srv-01/databases/database --operation merge --tags ApplicationOwner=‘test’

(InvalidResourceType) The resource type ‘locations/databaseOperationResults’ could not be found in the namespace ‘Microsoft.Sql’ for api version ‘2022-09-01’. The supported api-versions are ‘2017-03-01-preview,2017-10-01-preview,2018-06-01-preview,2019-06-01-preview,2020-02-02-preview,2020-08-01-preview,2020-11-01-preview,2021-02-01-preview,2021-05-01-preview,2021-08-01-preview,2021-11-01,2021-11-01-preview,2022-02-01-preview,2022-05-01-preview,2022-08-01-preview,2022-11-01-preview,2023-02-01-preview,2023-05-01-preview’. Code: InvalidResourceType Message: The resource type ‘locations/databaseOperationResults’ could not be found in the namespace ‘Microsoft.Sql’ for api version ‘2022-09-01’. The supported api-versions are ‘2017-03-01-preview,2017-10-01-preview,2018-06-01-preview,2019-06-01-preview,2020-02-02-preview,2020-08-01-preview,2020-11-01-preview,2021-02-01-preview,2021-05-01-preview,2021-08-01-preview,2021-11-01,2021-11-01-preview,2022-02-01-preview,2022-05-01-preview,2022-08-01-preview,2022-11-01-preview,2023-02-01-preview,2023-05-01-preview’.

image