Azure Java SDK version 1.33.1 doesn't have an inbuilt MySQL management client yet. However, you can use Maven dependency mentioned here
The entry class should be MySQLManager
.
Here is a sample code that I have written to create a MySQL server instance using the same client.
@Override
public Server createMySQLServer(AzureTokenCredentials credential,
AzureMySqlModel model) {
if (credential == null || model == null)
return null;
Server server = null;
if (model.validate()) {
try {
ServerPropertiesForDefaultCreate defaultProp = new ServerPropertiesForDefaultCreate();
ServerPropertiesForCreate withVersion = defaultProp.withAdministratorLogin(
model.getAdministratorLogin()).withAdministratorLoginPassword(
model.getAdministratorPassword()).withVersion(
model.getServerVersion());
server = MySQLManager.configure().withLogLevel(
LogLevel.BODY).authenticate(credential,
credential.defaultSubscriptionId()).servers().define(
model.getServerName()).withRegion(
model.getRegion()).withExistingResourceGroup(
model.getResourceGroup()).withProperties(
withVersion).create();
} catch (Exception ex) {
log.error("Error creating MySQL server {}", ex.getMessage());
}
}
return server;
}
AzureMySqlModel
is just a custom Java POJO to get the required details for creating a MySQL server.