How to fetch flexible server(providers/Microsoft.DBforPostgreSQL/flexibleServers/) configurations in java?

Tasleema Shaik Mohammed 71 Reputation points
2022-10-06T11:14:18.67+00:00

I have a requirement to fetch/update(through java SDK) flexible server configurations for which rest APIs are already available. But, only server options are available from java SDK. And I was getting a 404 error every time I try to get configurations with my resource group name/server name

Rest API details: https://learn.microsoft.com/en-us/rest/api/postgresql/flexibleserver(preview)/configurations/update?tabs=HTTP
Java Example details: https://github.com/Azure/azure-sdk-for-java/blob/azure-resourcemanager-postgresql_1.0.2/sdk/postgresql/azure-resourcemanager-postgresql/src/samples/java/com/azure/resourcemanager/postgresql/generated/ConfigurationsCreateOrUpdateSamples.java
Error:

Exception in thread "main" com.azure.core.management.exception.ManagementException: Status code 404, "{"error":{"code":"ResourceNotFound","message":"The Resource 'Microsoft.DBforPostgreSQL/servers/<MY_RESOURCE_GROUP_NAME>' under resource group '<MY_RESOURCE_GROUP_NAME>' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix"}}": The Resource 'Microsoft.DBforPostgreSQL/servers/<MY_FLEXIBLE_SERVER_NAME>' under resource group '<MY_RESOURCE_GROUP_NAME>' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:732)

Any ideas would be helpful, thanks!

SQL Server on Azure Virtual Machines
Azure Database for PostgreSQL
0 comments No comments
{count} votes

Accepted answer
  1. Saurabh Sharma 23,751 Reputation points Microsoft Employee
    2022-10-08T01:32:18.513+00:00

    Hi @Tasleema Shaik Mohammed ,

    Thanks for using Microsoft Q&A !!
    I believe you are trying to update the configuration with Postgres Single server sample code and thus getting this error. Instead, you need to use the Postgres Flexible server sample available over here ConfigurationsPutSamples.java which will be similar like below -

    public static void configurationCreateOrUpdate(PostgreSqlManager manager,String resourceGroup,String serverName) {  
            manager  
                .configurations()  
                .define("array_nulls")  
                .withExistingFlexibleServer(resourceGroup, serverName)  
                .withValue("off")  
                .withSource("user-override")  
                .create();  
        }  
    

    Please let me know if that's not the case and you still see issues using SDK to update your flexible server configuration.

    Thanks
    Saurabh

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful