0

This is the question about the Azure Management Libraries for Java.

First, some background:

The Azure Management REST API mentions at the createorupdate definition the ability to create the database and set different database properties like this (example from the page):

{
  "location": "southeastasia",
  "sku": {
    "name": "S0",
    "tier": "Standard"
  },
  "properties": {
    "createMode": "Default",
    "collation": "SQL_Latin1_General_CP1_CI_AS",
    "maxSizeBytes": 1073741824
  }
}

I'm looking how to do the similar request from the Azure Management Libraries for Java.

So far I have found how to set the "sku" part. This is done by using the appropriate ServiceObjectiveName object:

final SqlServer sqlServer = ...get SQL server object ...;

final Creatable<SqlDatabase> myDb = sqlServer.databases()
            .define(targetDBName)
            .withServiceObjective(ServiceObjectiveName.fromString("S0"));
...

myDb.createAsync(...); // create the db with sku S0

But I can't figure out how to set the properties. For my purpose I need to set a bit different properties than in the sample. Namely, the specific properties.maxSizeBytes and properties.autoPauseDelay.

I even found the .withMaxSizeBytes() method here but it's marked deprecated without any explanation.

I haven't found any way to set the autoPauseDelay.

Ruslan Bes
  • 2,715
  • 2
  • 25
  • 32

1 Answers1

1

By digging in the azure-sdk-for-java, I am sorry that I did not find any methods for setting these properties.

The complicated workaround I think of is to use resource deployment. It is supported in java sdk:

azure.deployments().define(deploymentName)
        .withExistingResourceGroup(rgName)
        .withTemplate(templateJson)
        .withParameters("{}")
        .withMode(DeploymentMode.INCREMENTAL)
        .create();

And here is a sample which can give you some guidance: DeployUsingARMTemplate

By the way, you can try to create a database on Azure portal, and then you can download the template at the last step of the creation:

enter image description here

Jack Jia
  • 5,268
  • 1
  • 12
  • 14