0

I do an up scale with a code like this on an Azure SQL Database:

ALTER DATABASE [MYDATABASE] Modify (SERVICE_OBJECTIVE = 'S1');

How is it possible to know from a c# code when Azure has completed the job and the table is already available?

Checking for SERVICE_OBJECTIVE value is not enough, the process still continue further.

1 Answer 1

1

Instead of performing this task in T-SQL I would perform the task from C# using an API call over to the REST API, you can find all of the details on MSDN.

Specifically, you should look at the Get Create or Update Database Status API method which allows you to call the following URL:

GET     https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Sql/servers/{server-name}/databases/{database-name}}/operationResults/{operation-id}?api-version={api-version}

The JSON body allows you to pass the following parameters:

{
    "id": "{uri-of-database}",
    "name": "{database-name}",
    "type": "{database-type}",
    "location": "{server-location}",
    "tags": {
        "{tag-key}": "{tag-value}",
        ...
    },
     "properties": {
        "databaseId": "{database-id}",
        "edition": "{database-edition}",
        "status": "{database-status}",
        "serviceLevelObjective": "{performance-level}",
        "collation": "{collation-name}",
        "maxSizeBytes": {max-database-size},
        "creationDate": "{date-create}",
        "currentServiceLevelObjectiveId":"{current-service-id}",
        "requestedServiceObjectiveId":"{requested-service-id}",
        "defaultSecondaryLocation": "{secondary-server-location}"
    }
}

In the properties section, the serviceLevelObjective property is the one you can use to resize the database. To finish off you can then perform a GET on the Get Database API method where you can compare both the currentServiceLevelObjectiveId and requestedServiceObjectiveId properties to ensure your command has been successful.

Note: Don't forget to pass all of the common parameters required to make API calls in Azure.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.