azure-sdk-for-java icon indicating copy to clipboard operation
azure-sdk-for-java copied to clipboard

[BUG] com.azure.resourcemanager.mysqlflexibleserver.models.Server object always returns "Enabled" for publicNetworkAccess property

Open gabrielspaulino opened this issue 1 year ago • 11 comments

Describe the bug MySQL Flexible server objects returned by com.azure.resourcemanager.mysqlflexibleserver.MySqlManager.servers().list() always return "Enabled" value for Server.innerModel().network().publicNetworkAccess()

Exception or Stack Trace There isn't any exception.

To Reproduce Call method com.azure.resourcemanager.mysqlflexibleserver.MySqlManager.servers().list() before and after disabling public access for your MySQL server.

Code Snippet image

Expected behavior The expected return for com.azure.resourcemanager.mysqlflexibleserver.models.Server.innerModel().network().publicNetworkAccess() is PublicNetworkAccessEnum.DISABLED when public access is disabled in the MySQL server

Screenshots Before disabling public access: image After disabling public access: image image

Setup (please complete the following information):

  • OS: Windows 11
  • IDE: IntelliJ
  • Library/Libraries: com.azure:azure-resourcemanager:2.25.0
  • Java version: 17
  • App Server/Environment:
  • Frameworks: Spring Boot

Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • [X] Bug Description Added
  • [X] Repro Steps Added
  • [X] Setup information Added

gabrielspaulino avatar Aug 22 '24 15:08 gabrielspaulino

Thank you for your feedback. Tagging and routing to the team member best able to assist.

github-actions[bot] avatar Aug 22 '24 15:08 github-actions[bot]

Hi @gabrielspaulino

Is it possible for you to enable logging and check the JSON response of the List after disabling the public access? https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/resourcemanager#enabling-logging

PS: if you paste it in this issue, please redact any sensitive information.

I believe SDK here is directly return what it gets from backend in this JSON. We will need to forward it to backend, if their response is wrong.

PS: if possible, please include version of azure-resourcemanager-mysqlflexibleserver lib

weidongxu-microsoft avatar Aug 23 '24 01:08 weidongxu-microsoft

Hi @weidongxu-microsoft

Sorry, logging is already enabled but how can I get the JSON response?

The version of azure-resourcemanager-mysqlflexibleserver lib that I'm using is 1.0.0-beta.2

gabrielspaulino avatar Aug 23 '24 15:08 gabrielspaulino

One thing I found is that the Network class does not have withPublicNetworkAccess. It could be that changing "publicNetworkAccess" is not supported in api-version of the 1.0.0-beta.2 SDK in Azure MySql backend. https://github.com/Azure/azure-sdk-for-java/blob/azure-resourcemanager-mysqlflexibleserver_1.0.0-beta.2/sdk/mysqlflexibleserver/azure-resourcemanager-mysqlflexibleserver/src/main/java/com/azure/resourcemanager/mysqlflexibleserver/models/Network.java#L32-L40

If you check latest 1.0.0-beta.5 SDK, the withPublicNetworkAccess API exists. https://github.com/Azure/azure-sdk-for-java/blob/azure-resourcemanager-mysqlflexibleserver_1.0.0-beta.5/sdk/mysqlflexibleserver/azure-resourcemanager-mysqlflexibleserver/src/main/java/com/azure/resourcemanager/mysqlflexibleserver/models/Network.java#L39-L59

weidongxu-microsoft avatar Aug 26 '24 01:08 weidongxu-microsoft

Where logging goes depends on the logging lib you use, and the config of it.

The output should be something like below:

09:56:01.172 INFO  [parallel-10]  - {"az.sdk.message":"HTTP request","method":"GET","url":"https://management.azure.com/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/providers/Microsoft.DBforMySQL/locations/westus3/azureAsyncOperation/2ba32795-15b5-4e55-b77b-f77160081a99?api-version=2023-12-30&t=REDACTED&c=REDACTED&s=REDACTED&h=REDACTED","tryCount":1,"Date":"Mon, 26 Aug 2024 01:56:01 GMT","x-ms-client-request-id":"3a2aabae-da0c-4706-942b-9a948077b89b","Accept":"application/json","User-Agent":"azsdk-java-com.azure.resourcemanager.mysqlflexibleserver/1.0.0-beta.5 (21.0.3; Windows 11; 10.0; auto-generated)","redactedHeaders":"Authorization"}
09:56:01.734 INFO  [reactor-http-nio-1]  - {"az.sdk.message":"HTTP response","statusCode":200,"url":"https://management.azure.com/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/providers/Microsoft.DBforMySQL/locations/westus3/azureAsyncOperation/2ba32795-15b5-4e55-b77b-f77160081a99?api-version=2023-12-30&t=REDACTED&c=REDACTED&s=REDACTED&h=REDACTED","durationMs":562,"content-length":264,"content-length":264,"body":"{\"name\":\"2ba32795-15b5-4e55-b77b-f77160081a99\",\"status\":\"Failed\",\"startTime\":\"2024-08-26T01:55:00.88Z\",\"error\":{\"code\":\"InternalServerError\",\"message\":\"An unexpected error occured while processing the request. Tracking ID: 'de1cc453-a8a6-476d-bece-f96f6b1ef1e9'\"}}"}

I am having problem creating MySql resource on my test subscription (as you can see on above log), hence I cannot verify whether 1.0.0-beta.5 is good on "publicNetworkAccess" in List.

weidongxu-microsoft avatar Aug 26 '24 02:08 weidongxu-microsoft

I tested updating to 1.0.0-beta.5 and it is also always returning "Enabled"

gabrielspaulino avatar Aug 26 '24 21:08 gabrielspaulino

Do you see the log?

weidongxu-microsoft avatar Aug 27 '24 06:08 weidongxu-microsoft

I got the JSON response from chrome inspector, does this work? It has publicNetworkAccess as "Disabled". Here it is (I removed some information): { "responses": [ { "httpStatusCode": 200, "headers": { "Pragma": ---, "X-Content-Type-Options": ---, "x-ms-request-id": ---, "x-ms-ratelimit-remaining-subscription-reads": ---, "x-ms-ratelimit-remaining-subscription-global-reads": ---, "x-ms-correlation-request-id": ---, "x-ms-routing-request-id": ---, "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Cache": "CONFIG_NOCACHE", "X-MSEdge-Ref": ---, "Cache-Control": "no-cache", "Date": "Tue, 27 Aug 2024 20:32:33 GMT" }, "content": { "sku": { "name": "Standard_B1ms", "tier": "Burstable" }, "systemData": { "createdAt": "2024-08-27T20:22:34.4853383Z" }, "properties": { "administratorLogin": ---, "storage": { "storageSizeGB": 20, "iops": 360, "autoGrow": "Enabled", "autoIoScaling": "Enabled", "storageSku": "Premium_LRS", "logOnDisk": "Disabled" }, "version": "8.0.21", "state": "Ready", "fullyQualifiedDomainName": "mysql-sek-test.mysql.database.azure.com", "availabilityZone": "1", "maintenanceWindow": { "customWindow": "Disabled", "dayOfWeek": 0, "startHour": 0, "startMinute": 0 }, "replicationRole": "None", "replicaCapacity": 10, "network": { "publicNetworkAccess": "Disabled" }, "backup": { "backupRetentionDays": 7, "geoRedundantBackup": "Disabled", "earliestRestoreDate": "2024-08-27T20:27:33.2791802+00:00" }, "highAvailability": { "mode": "Disabled", "state": "NotEnabled", "standbyAvailabilityZone": "" }, "privateEndpointConnections": [] }, "location": "East US", "tags": {}, "id": ---, "name": "mysql-sek-test", "type": "Microsoft.DBforMySQL/flexibleServers" }, "contentLength": 1094 } ] }

gabrielspaulino avatar Aug 27 '24 20:08 gabrielspaulino

Finally I get one created in another test subscription.

listByResourceGroup works fine on my test. image

list also works. image

Here is the log

"body":"{\"value\":[{\"sku\":{\"name\":\"Standard_B1ms\",\"tier\":\"Burstable\"},\"systemData\":{\"createdAt\":\"2024-08-28T02:29:06.1401709Z\"},\"properties\":{\"administratorLogin\":\"sqlAdminWeidxu\",\"storage\":{\"storageSizeGB\":20,\"iops\":360,\"autoGrow\":\"Enabled\",\"autoIoScaling\":\"Disabled\",\"storageSku\":\"Premium_LRS\",\"logOnDisk\":\"Disabled\"},\"version\":\"5.7\",\"state\":\"Ready\",\"fullyQualifiedDomainName\":\"mysqlweidxu123.mysql.database.azure.com\",\"availabilityZone\":\"\",\"replicationRole\":\"None\",\"replicaCapacity\":10,\"network\":{\"publicNetworkAccess\":\"Disabled\"}, ...

(note that the response of the List should have { value: [] } in body)

Test on 1.0.0-beta.5

You may want to check whether the azure-core lib in your app is up-to-date. It handles the de-serialization. https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/resourcemanager#dependency-management

weidongxu-microsoft avatar Aug 28 '24 02:08 weidongxu-microsoft

Hi @gabrielspaulino. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

github-actions[bot] avatar Aug 28 '24 02:08 github-actions[bot]

I tried with the following versions: azure-resourcemanager-mysqlflexibleserver - 1.0.0-beta.5 azure-core - 1.51.0 azure-resourcemanager - 2.42.0 but it didn't work for me utilizing the SDK. When making the request directly for this URL it worked. https://learn.microsoft.com/en-us/rest/api/mysql/flexibleserver/servers/list?view=rest-mysql-flexibleserver-2023-12-30&tabs=HTTP Here is the response: {"value":[{"sku":{"name":"Standard_B1ms","tier":"Burstable"},"systemData":{"createdAt":"2024-08-29T20:56:28.9920341Z"},"properties":{"administratorLogin":---,"storage":{"storageSizeGB":20,"iops":360,"autoGrow":"Enabled","autoIoScaling":"Enabled","storageSku":"Premium_LRS","logOnDisk":"Disabled"},"version":"8.0.21","state":"Ready","fullyQualifiedDomainName":---,"availabilityZone":"2","replicationRole":"None","replicaCapacity":10,"network":{"publicNetworkAccess":"Disabled"},"backup":{"backupRetentionDays":7,"geoRedundantBackup":"Disabled","earliestRestoreDate":"2024-08-29T20:59:43.4578412+00:00"},"highAvailability":{"mode":"Disabled","state":"NotEnabled","standbyAvailabilityZone":""},"privateEndpointConnections":[]},"location":"East US","tags":{},"id":---,"name":"mysql-sek-test","type":"Microsoft.DBforMySQL/flexibleServers"}]}

gabrielspaulino avatar Aug 29 '24 21:08 gabrielspaulino

Hi @weidongxu-microsoft. Is there any other maven artifcact I should update? As I said in the last comment, it is still not working for me with the versions you suggested.

gabrielspaulino avatar Sep 19 '24 15:09 gabrielspaulino

Hi @weidongxu-microsoft. Is there any other maven artifcact I should update? As I said in the last comment, it is still not working for me with the versions you suggested.

Do you see the log of the HTTP response printed by SDK?

You may also want to check the version of azure-core lib (which is used to de-serialize the HTTP response to that of the SDK model/class). And make it as up-to-date as possible. See https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/resourcemanager#dependency-management

weidongxu-microsoft avatar Sep 20 '24 02:09 weidongxu-microsoft

I've check in my side that SDK de-serialize is correct, and the runtime value is also correct.

But maybe this is a backend issue that associate with some specific MySQL instance. Maybe for an instance created via older api-version (where this property is not settable), it's property value cannot be correctly retrieved in a new api-version.

Maybe you can open a support ticket, in order for the support to track the request/response via request ID.

weidongxu-microsoft avatar Sep 25 '24 02:09 weidongxu-microsoft

Hi @gabrielspaulino. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

github-actions[bot] avatar Oct 08 '25 20:10 github-actions[bot]

Hi @gabrielspaulino, we're sending this friendly reminder because we haven't heard back from you in 7 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

github-actions[bot] avatar Oct 18 '25 03:10 github-actions[bot]