/// <summary> /// Process the record with the provided server name /// </summary> /// <param name="databaseName">The name of the database to retrieve</param> private void ProcessWithServerName(string databaseName) { Func <string> GetClientRequestId = () => string.Empty; try { // Get the current subscription data. WindowsAzureSubscription subscription = WindowsAzureProfile.Instance.CurrentSubscription; // create a temporary context ServerDataServiceCertAuth context = ServerDataServiceCertAuth.Create(this.ServerName, subscription); GetClientRequestId = () => context.ClientRequestId; if (databaseName != null) { // Retrieve the database with the specified name this.WriteObject(context.GetDatabase(databaseName)); } else { // No name specified, retrieve all databases in the server this.WriteObject(context.GetDatabases()); } } catch (Exception ex) { SqlDatabaseExceptionHandler.WriteErrorDetails( this, GetClientRequestId(), ex); } }
/// <summary> /// Process the record with the provided server name /// </summary> /// <param name="databaseName">The name of the database to retrieve</param> private void ProcessWithServerName(string databaseName) { string clientRequestId = string.Empty; try { // Get the current subscription data. SubscriptionData subscriptionData = this.GetCurrentSubscription(); // create a temporary context ServerDataServiceCertAuth context = ServerDataServiceCertAuth.Create(this.ServerName, subscriptionData); clientRequestId = context.ClientRequestId; if (databaseName != null) { // Retrieve the database with the specified name this.WriteObject(context.GetDatabase(databaseName)); } else { // No name specified, retrieve all databases in the server this.WriteObject(context.GetDatabases()); } } catch (Exception ex) { SqlDatabaseExceptionHandler.WriteErrorDetails( this, clientRequestId, ex); } }
public void GetAzureSqlDatabaseWithCertAuth() { SimpleSqlDatabaseManagement channel = new SimpleSqlDatabaseManagement(); channel.GetDatabaseThunk = ar => { Assert.AreEqual( ar.Values["databaseName"], "testdb1", "The input databaseName did not match the expected"); SqlDatabaseResponse db1 = new SqlDatabaseResponse(); db1.CollationName = "Japanese_CI_AS"; db1.Edition = "Web"; db1.Id = "1"; db1.MaxSizeGB = "1"; db1.Name = "testdb1"; db1.CreationDate = DateTime.Now.ToString(); db1.IsFederationRoot = true.ToString(); db1.IsSystemObject = true.ToString(); db1.MaxSizeBytes = "1073741824"; return(db1); }; SubscriptionData subscriptionData = UnitTestHelper.CreateUnitTestSubscription(); subscriptionData.ServiceEndpoint = MockHttpServer.DefaultHttpsServerPrefixUri.AbsoluteUri; NewAzureSqlDatabaseServerContext contextCmdlet = new NewAzureSqlDatabaseServerContext(); ServerDataServiceCertAuth service = contextCmdlet.GetServerDataServiceByCertAuth("TestServer", subscriptionData); service.Channel = channel; Database database = service.GetDatabase("testdb1"); Assert.AreEqual("testdb1", database.Name, "Expected db name to be testdb1"); Assert.AreEqual( "Japanese_CI_AS", database.CollationName, "Expected collation to be Japanese_CI_AS"); Assert.AreEqual("Web", database.Edition, "Expected edition to be Web"); Assert.AreEqual(1, database.MaxSizeGB, "Expected max size to be 1 GB"); }