/// <summary> /// Creates and returns a new instance of the <see cref="ServerDataServiceCertAuth"/> class /// which connects to the specified server using the specified subscription credentials. /// </summary> /// <param name="subscription">The subscription used to connect and authenticate.</param> /// <param name="serverName">The name of the server to connect to.</param> /// <returns>An instance of <see cref="ServerDataServiceCertAuth"/> class.</returns> public static ServerDataServiceCertAuth Create( string serverName, WindowsAzureSubscription subscription) { if (string.IsNullOrEmpty(serverName)) { throw new ArgumentException("serverName"); } SqlDatabaseCmdletBase.ValidateSubscription(subscription); // Create a new ServerDataServiceCertAuth object to be used return(new ServerDataServiceCertAuth( subscription, serverName)); }
/// <summary> /// Connect to Azure SQL Server using certificate authentication. /// </summary> /// <param name="serverName">The name of the server to connect to</param> /// <param name="subscription">The subscription data to use for authentication</param> /// <returns>A new <see cref="ServerDataServiceCertAuth"/> context, /// or <c>null</c> if an error occurred.</returns> internal ServerDataServiceCertAuth GetServerDataServiceByCertAuth( string serverName, IAzureSubscription subscription) { ServerDataServiceCertAuth context = null; SqlDatabaseCmdletBase.ValidateSubscription(subscription); try { context = ServerDataServiceCertAuth.Create(serverName, Profile, subscription); } catch (ArgumentException e) { SqlDatabaseExceptionHandler.WriteErrorDetails(this, string.Empty, e); context = null; } return(context); }