Creating a Server with current nuget packages?

Copper Contributor

I want to programmatically create an Azure SQL Server and I found an example piece of code online

static void CreateServer()
{
    // Create a SQL Database management client
    SqlManagementClient sqlClient = new SqlManagementClient(new TokenCloudCredentials(subscriptionId, token.AccessToken));

    // Create a server
    ServerCreateOrUpdateParameters serverParameters = new ServerCreateOrUpdateParameters()
    {
        Location = location,
        Properties = new ServerCreateOrUpdateProperties()
        {
            AdministratorLogin = administratorLogin,
            AdministratorLoginPassword = administratorPassword,
            Version = serverVersion
        }
    };
        var serverResult = sqlClient.Servers.CreateOrUpdate(resourceGroupName, serverName, serverParameters);
}

... but I have since found that the packages I need for this are deprecated. Instead of Microsoft.Azure.Management.Sql.Fluent I should be using Azure.ResourceManager.Sql

But I can't find any example as clear as the above to create a new Azure SQL server using the new packages. This is an area I'm very unfamiliar with so I can't see the wood for the trees and I get lost in the definitions. Can someone please provide a code snippet as minimalistic as the above to achieve the same thing using new packages?

Many thanks.

0 Replies