예제 #1
0
        /// <summary>
        /// Process the request using the server name
        /// </summary>
        /// <param name="maxSizeGb">the maximum size of the database</param>
        private void ProcessWithServerName(int?maxSizeGb)
        {
            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;

                // Retrieve the database with the specified name
                this.WriteObject(context.CreateNewDatabase(
                                     this.DatabaseName,
                                     maxSizeGb,
                                     this.Collation,
                                     this.Edition,
                                     this.ServiceObjective));
            }
            catch (Exception ex)
            {
                SqlDatabaseExceptionHandler.WriteErrorDetails(
                    this,
                    GetClientRequestId(),
                    ex);
            }
        }
예제 #2
0
        /// <summary>
        /// Process the request using the server name
        /// </summary>
        /// <param name="maxSizeGb">the maximum size of the database</param>
        private void ProcessWithServerName(int?maxSizeGb)
        {
            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;

                // Retrieve the database with the specified name
                this.WriteObject(context.CreateNewDatabase(
                                     this.DatabaseName,
                                     maxSizeGb,
                                     this.Collation,
                                     this.Edition));
            }
            catch (Exception ex)
            {
                SqlDatabaseExceptionHandler.WriteErrorDetails(
                    this,
                    clientRequestId,
                    ex);
            }
        }
예제 #3
0
        public void NewAzureSqlDatabaseWithCertAuth()
        {
            SimpleSqlDatabaseManagement channel = new SimpleSqlDatabaseManagement();

            channel.NewDatabaseThunk = ar =>
            {
                Assert.AreEqual(
                    ((SqlDatabaseInput)ar.Values["input"]).Name,
                    "UnitTestNewDatabase",
                    "The database Name input parameter does not match");
                Assert.AreEqual(
                    ((SqlDatabaseInput)ar.Values["input"]).MaxSizeGB,
                    "1",
                    "The database MaxSizeGB input parameter does not match");
                Assert.AreEqual(
                    ((SqlDatabaseInput)ar.Values["input"]).CollationName,
                    "Japanese_CI_AS",
                    "The database CollationName input parameter does not match");
                Assert.AreEqual(
                    ((SqlDatabaseInput)ar.Values["input"]).Edition,
                    "Web",
                    "The database Edition input parameter does not match");

                SqlDatabaseResponse operationResult = new SqlDatabaseResponse();
                operationResult.CollationName    = "Japanese_CI_AS";
                operationResult.Edition          = "Web";
                operationResult.Id               = "1";
                operationResult.MaxSizeGB        = "1";
                operationResult.Name             = "TestDatabaseName";
                operationResult.CreationDate     = DateTime.Now.ToString();
                operationResult.IsFederationRoot = true.ToString();
                operationResult.IsSystemObject   = true.ToString();
                operationResult.MaxSizeBytes     = "1073741824";

                return(operationResult);
            };

            SubscriptionData subscriptionData = UnitTestHelper.CreateUnitTestSubscription();

            subscriptionData.ServiceEndpoint = MockHttpServer.DefaultHttpsServerPrefixUri.AbsoluteUri;

            NewAzureSqlDatabaseServerContext contextCmdlet = new NewAzureSqlDatabaseServerContext();

            ServerDataServiceCertAuth service =
                contextCmdlet.GetServerDataServiceByCertAuth("TestServer", subscriptionData);

            service.Channel = channel;

            Database result =
                service.CreateNewDatabase("UnitTestNewDatabase", 1, "Japanese_CI_AS", DatabaseEdition.Web);

            // Verify that the result matches the stuff in the thunk.
            Assert.AreEqual(result.CollationName, "Japanese_CI_AS", "The collation does not match");
            Assert.AreEqual(result.Edition, DatabaseEdition.Web.ToString(), "The edition does not match");
            Assert.AreEqual(result.MaxSizeGB, 1, "The max db size does not match");
            Assert.AreEqual(result.Name, "TestDatabaseName", "The name does not match");
        }
예제 #4
0
        /// <summary>
        /// Process the request using the server name
        /// </summary>
        /// <param name="maxSizeGb">the maximum size of the database</param>
        /// <param name="maxSizeBytes"></param>
        private void ProcessWithServerName(int?maxSizeGb, long?maxSizeBytes)
        {
            Func <string> GetClientRequestId = () => string.Empty;

            try
            {
                // Get the current subscription data.
                AzureSubscription subscription = Profile.Context.Subscription;

                // Create a temporary context
                ServerDataServiceCertAuth context =
                    ServerDataServiceCertAuth.Create(this.ServerName, Profile, subscription);

                GetClientRequestId = () => context.ClientRequestId;

                Services.Server.Database response = context.CreateNewDatabase(
                    this.DatabaseName,
                    maxSizeGb,
                    maxSizeBytes,
                    this.Collation,
                    this.Edition,
                    this.ServiceObjective);

                response = CmdletCommon.WaitForDatabaseOperation(this, context, response, this.DatabaseName, true);

                // Retrieve the database with the specified name
                this.WriteObject(response);
            }
            catch (Exception ex)
            {
                SqlDatabaseExceptionHandler.WriteErrorDetails(
                    this,
                    GetClientRequestId(),
                    ex);
            }
        }