/// <summary> /// Converts the given model into the API parameters object /// </summary> /// <param name="model"></param> /// <returns></returns> protected ServerCreateOrUpdateParameters CreateOptions(SqlServer model) { var props = new ServerCreateOrUpdateProperties { AdministratorLogin = model.Username, AdministratorLoginPassword = model.Secret, Version = SqlServerVersion }; return(new ServerCreateOrUpdateParameters { Location = Region.Location, Properties = props }); }
// This works with a native application not with a web application // Perhaps using a native app is required for now static void CreateSqlServer(TokenCloudCredentials creds) { var client = new SqlManagementClient(creds); var someProperties = new ServerCreateOrUpdateProperties { AdministratorLogin = adminAccountName, AdministratorLoginPassword = adminAccountPwd, Version = "12" }; var parameters = new ServerCreateOrUpdateParameters(someProperties, location); ServerGetResponse aCreateResponse = client.Servers.CreateOrUpdate(resourceGroupName, serverName, parameters); }
static void CreateSqlServer(TokenCloudCredentials creds) { var client = new SqlManagementClient(creds); var someProperties = new ServerCreateOrUpdateProperties { AdministratorLogin = adminAccountName, AdministratorLoginPassword = adminAccountPwd, Version = "12" }; var parameters = new ServerCreateOrUpdateParameters(someProperties, location); // { "AuthorizationFailed: The client 'xxxxx-xxxxx-xxxxx-xxxxx' // with object id 'xxxxx-xxxxx-xxxxx-xxxxx' does not have authorization // to perform action 'Microsoft.Sql/servers/write' over scope // '/subscriptions/xxxxx-xxxxx-xxxxx-xxxxx/resourceGroups/MY_RESOURCE_GROUP_NAME/providers/Microsoft.Sql/servers/MY_SERVER_NAME'."} ServerGetResponse aCreateResponse = client.Servers.CreateOrUpdate(resourceGroupName, serverName, parameters); }