Azure / azure-sdk-for-java

This repository is for active development of the Azure SDK for Java. For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/java/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-java.
MIT License
2.33k stars 1.97k forks source link

[BUG] "No registered resource provider found for location 'eastus2' and API version '2018-01-01' for type 'storageAccounts/blobServices' #39123

Open gokhandegerli opened 7 months ago

gokhandegerli commented 7 months ago

Describe the bug I am using Java SDK or API, and getting below error while trying to create an alert rule for a container which locates on eastus2. I can not figure out where"API version '2018-01-01' " is coming from, on API call, I am using a different API version. I think something is doing this API call at the background (might be related with container since it's region is eastus2, I really do not know). I would be really appreciate if anyone helps, thanks in advance.

{

"code": "ResourceNotFound",

"message": "No registered resource provider found for location 'eastus2' and API version '2018-01-01' for type 'storageAccounts/blobServices'. The supported api-versions are '2023-05-01, 2023-04-01, 2023-01-01, 2022-09-01, 2022-05-01, 2021-09-01, 2021-08-01, 2021-06-01, 2021-05-01, 2021-04-01, 2021-02-01, 2021-01-01, 2020-08-01-preview, 2019-06-01, 2019-04-01, 2018-11-01, 2018-07-01, 2018-03-01-preview, 2018-02-01, 2017-10-01, 2017-06-01, 2016-12-01, 2016-05-01'. The supported locations are 'eastus, eastus2, westus, westeurope, eastasia, southeastasia, japaneast, japanwest, northcentralus, southcentralus, centralus, northeurope, brazilsouth, australiaeast, australiasoutheast, southindia, centralindia, westindia, canadaeast, canadacentral, westus2, westcentralus, uksouth, ukwest, koreacentral, koreasouth, francecentral, australiacentral, southafricanorth, uaenorth, switzerlandnorth, germanywestcentral, norwayeast, westus3, jioindiawest, swedencentral, qatarcentral, polandcentral, italynorth, israelcentral'. Activity ID: c379a2e1-9633-48b7-9b5a-4c9d7199a8dd."

}

Exception or Stack Trace { "code": "alert.azure.upsert_alert_error", "message": "AZURE Upsert Alert error: Status code 400, \"{\"code\":\"ResourceNotFound\",\"message\":\"No registered resource provider found for location 'eastus2' and API version '2018-01-01' for type 'storageAccounts/blobServices'. The supported api-versions are '2023-05-01, 2023-04-01, 2023-01-01, 2022-09-01, 2022-05-01, 2021-09-01, 2021-08-01, 2021-06-01, 2021-05-01, 2021-04-01, 2021-02-01, 2021-01-01, 2020-08-01-preview, 2019-06-01, 2019-04-01, 2018-11-01, 2018-07-01, 2018-03-01-preview, 2018-02-01, 2017-10-01, 2017-06-01, 2016-12-01, 2016-05-01'. The supported locations are 'eastus, eastus2, westus, westeurope, eastasia, southeastasia, japaneast, japanwest, northcentralus, southcentralus, centralus, northeurope, brazilsouth, australiaeast, australiasoutheast, southindia, centralindia, westindia, canadaeast, canadacentral, westus2, westcentralus, uksouth, ukwest, koreacentral, koreasouth, francecentral, australiacentral, southafricanorth, uaenorth, switzerlandnorth, germanywestcentral, norwayeast, westus3, jioindiawest, swedencentral, qatarcentral, polandcentral, italynorth, israelcentral'. Activity ID: 11113178-a84d-406b-b49f-75c6c65dce8c.\"}\", for y0jgd4j4f1-BlobCount01" }

Code Snippet Response orUpdateWithResponse = azureResourceManager.diagnosticSettings() .manager() .serviceClient() .getMetricAlerts() .createOrUpdateWithResponse(storageResourceGroup, dto.getName(), new MetricAlertResourceInner().withLocation(region) .withDescription(dto.getDescription()) .withSeverity(3) .withEnabled(true) .withScopes(List.of("/subscriptions/" + subscriptionId + "/resourceGroups/"

Expected behavior I am expecting it creates an alert (by the way it creates an action group)

Setup (please complete the following information):

gokhandegerli commented 7 months ago

https://learn.microsoft.com/en-us/answers/questions/1610981/trying-to-create-an-alert-by-means-of-java-sdk-or

joshfree commented 7 months ago

@weidongxu-microsoft could you please follow up

weidongxu-microsoft commented 7 months ago

@gokhandegerli

The api-version SDK sent to monitor MetricAlert should be 2018-03-01 https://github.com/Azure/azure-sdk-for-java/blob/azure-resourcemanager-monitor_2.36.0/sdk/resourcemanager/azure-resourcemanager-monitor/src/main/java/com/azure/resourcemanager/monitor/implementation/MetricAlertsClientImpl.java#L522

The api-version 2018-01-01 appears to be completely in backend implementation when it work on the storage account.

Would it possible for you to enable the logging, and share the URL and JSON request body? (redact anything that could be sensitive)?

We'd like to know whether we should ask backend to track the issue.

gokhandegerli commented 7 months ago

@weidongxu-microsoft

Please see below the API request details, however I do not know what you mean for enabling the logging.

PUT request URL: "https://management.azure.com/subscriptions/26e4c203-9a71-4ae0-a0e7-65dd5c086761/resourceGroups/c4c-gokhanalertestdev-qq6yviniqy/providers/Microsoft.Insights/metricAlerts/new01?api-version=2018-03-01"

JSON request body: { "location": "global", "properties": { "severity": 3, "autoMitigate": true, "windowSize": "PT1M", "criteria": { "allOf": [ { "metricName": "BlobCount", "timeAggregation": "AVERAGE", "criterionType": "StaticThresholdCriterion", "name": "y0jgd4j4f1-BlobCount01", "threshold": 10, "operator": "GreaterThan" } ], "odata.type": "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", "actions": [ { "actionGroupId": "/subscriptions/26E4C203-9A71-4AE0-A0E7-65DD5C086761/resourceGroups/c4c-gokhanalertestdev-qq6yviniqy/providers/microsoft.insights/actionGroups/newNG01" } ] }, "evaluationFrequency": "PT1M", "description": "BlobCount01", "scopes": [ "/subscriptions/26e4c203-9a71-4ae0-a0e7-65dd5c086761/resourceGroups/c4c-gokhanalertestdev-qq6yviniqy/providers/Microsoft.Storage/storageAccounts/gokhantestc4c212ftk/blobServices/default/containersy0jgd4j4f1c4c" ], "enabled": true } }

weidongxu-microsoft commented 7 months ago

@gokhandegerli

Thanks. The URL and payload is what we need. (logging just a way to print these)

There is nothing from SDK that specify 2018-01-01. This would be from backend (probably when it works on the storage account resource in scopes).

If you can open customer support ticket, it should be faster to handle this way, as it need to connect to backend dev to diagnose and fix.