コード例 #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, long? maxSizeBytes)
        {
            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;
                
                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);
            }
        }
コード例 #2
0
        /// <summary>
        /// Process the request using a temporary connection context using certificate authentication
        /// </summary>
        /// <param name="databaseName">The name of the database to update</param>
        /// <param name="maxSizeGb">the new size for the database or null</param>
        /// <param name="maxSizeBytes"></param>
        /// <param name="edition">the new edition for the database or null</param>
        private void ProcessWithServerName(string databaseName, int?maxSizeGb, long?maxSizeBytes, DatabaseEdition?edition)
        {
            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;

                // Remove the database with the specified name
                Services.Server.Database database = context.UpdateDatabase(
                    databaseName,
                    this.NewDatabaseName,
                    maxSizeGb,
                    maxSizeBytes,
                    edition,
                    this.ServiceObjective);

                if (this.Sync.IsPresent)
                {
                    // Wait for the operation to complete on the server.
                    database = CmdletCommon.WaitForDatabaseOperation(this, context, database, this.DatabaseName, false);
                }

                // Update the passed in database object
                if (this.MyInvocation.BoundParameters.ContainsKey("Database"))
                {
                    this.Database.CopyFields(database);
                    database = this.Database;
                }

                // If PassThru was specified, write back the updated object to the pipeline
                if (this.PassThru.IsPresent)
                {
                    this.WriteObject(database);
                }
            }
            catch (Exception ex)
            {
                SqlDatabaseExceptionHandler.WriteErrorDetails(
                    this,
                    GetClientRequestId(),
                    ex);
            }
        }
コード例 #3
0
        /// <summary>
        /// process the request using the connection context.
        /// </summary>
        /// <param name="databaseName">the name of the database to alter</param>
        /// <param name="maxSizeGb">the new maximum size for the database</param>
        /// <param name="maxSizeBytes"></param>
        /// <param name="edition">the new edition for the database</param>
        private void ProcessWithConnectionContext(string databaseName, int?maxSizeGb, long?maxSizeBytes, DatabaseEdition?edition)
        {
            try
            {
                // Update the database with the specified name
                Services.Server.Database database = this.ConnectionContext.UpdateDatabase(
                    databaseName,
                    this.NewDatabaseName,
                    maxSizeGb,
                    maxSizeBytes,
                    edition,
                    this.ServiceObjective);

                if (this.Sync.IsPresent)
                {
                    // Wait for the operation to complete on the server.
                    database = CmdletCommon.WaitForDatabaseOperation(this, this.ConnectionContext, database, this.DatabaseName, false);
                }

                // If PassThru was specified, write back the updated object to the pipeline
                if (this.PassThru.IsPresent)
                {
                    this.WriteObject(database);
                }

                if (this.ConnectionContext.GetType() == typeof(ServerDataServiceCertAuth))
                {
                    if (this.MyInvocation.BoundParameters.ContainsKey("Database"))
                    {
                        this.Database.CopyFields(database);
                    }
                }
            }
            catch (Exception ex)
            {
                SqlDatabaseExceptionHandler.WriteErrorDetails(
                    this,
                    this.ConnectionContext.ClientRequestId,
                    ex);
            }
        }
コード例 #4
0
        /// <summary>
        /// Process the request using the connection context.
        /// </summary>
        /// <param name="maxSizeGb">the maximum size for the new database</param>
        /// <param name="maxSizeBytes"></param>
        private void ProcessWithConnectionContext(int?maxSizeGb, long?maxSizeBytes)
        {
            try
            {
                Services.Server.Database database = this.ConnectionContext.CreateNewDatabase(
                    this.DatabaseName,
                    maxSizeGb,
                    maxSizeBytes,
                    this.Collation,
                    this.Edition,
                    this.ServiceObjective);

                database = CmdletCommon.WaitForDatabaseOperation(this, this.ConnectionContext, database, this.DatabaseName, true);

                this.WriteObject(database, true);
            }
            catch (Exception ex)
            {
                SqlDatabaseExceptionHandler.WriteErrorDetails(
                    this,
                    this.ConnectionContext.ClientRequestId,
                    ex);
            }
        }