Hello bonda29,
Welcome to the Microsoft Q&A and thank you for posting your questions here.
I understand that you would like to use the Azure Pricing API (https://prices.azure.com/api/retail/prices) to get pricing information with an instance of your SqlDatabase
in Java
You will need to construct an API request that will use the Azure Pricing API endpoint you identified https://prices.azure.com/api/retail/prices and apply filters to narrow down the specific SQL Database configuration requirement like Service Name, SKU Name, and Region. For an example:
GET https://prices.azure.com/api/retail/prices?$filter=serviceName eq 'Azure SQL Database' and skuName eq 'GP_S_Gen5' and armRegionName eq 'germanywestcentral
The below is an example of how your code should be in Java.
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class AzurePricingAPI {
public static void main(String[] args) {
try {
String url = "https://prices.azure.com/api/retail/prices?$filter=serviceName eq 'Azure SQL Database' and skuName eq 'GP_S_Gen5' and armRegionName eq 'germanywestcentral'";
HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
conn.setRequestMethod("GET");
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String inputLine;
StringBuffer content = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
content.append(inputLine);
}
in.close();
conn.disconnect();
System.out.println(content.toString());
} catch (Exception e) {
e.printStackTrace();
}
}
}
I hope this is helpful! Do not hesitate to let me know if you have any other questions.
Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.