How to set a server level objective (pricing tier) for an existing Azure SQL database in Azure fluent API for SQL Server?
I am using Microsoft.Azure.Management.Sql.Fluent, version 1.10.0, which is latest as of today.
This sample code provided by Microsoft creates an Azure SQL database, then sets its server level
var azCreds = SdkContext.AzureCredentialsFactory.FromFile(filePath);
var azure = Azure.Configure()
.Authenticate(azCreds)
.WithSubscription("mysubscriptionid");
var sqlServer =
azure.SqlServers.Define("existingsqlserverid")
.WithRegion(Region.USEast)
.WithExistingResourceGroup("Default-SQL-EastUS")
.WithAdministratorLogin("mylogin")
.WithAdministratorPassword("mypassword")
.Create()
.Databases
.Define("NewDbName")
.Create()
.Update()
.WithEdition(DatabaseEditions.Standard)
.WithServiceObjective(ServiceObjectiveName.S1)
.Apply();
How do I set the service level of an existing db?
The closest I can seem to get is
.WithAdministratorPassword("mypassword")
.DefineDatabase("OldDbName")
.WithEdition(DatabaseEditions.Standard)
.WithServiceObjective(ServiceObjectiveName.S2);
which doesn't throw exceptions but also doesn't do anything. The service level of the db doesn't change.
It feels like I need an Apply()
here, but that's not an option.
The Microsoft doc on the Azure Fluent API for SQL Server is very sparse.