Esempio n. 1
0
        /// <summary>
        /// Resets the administrator password for an existing server in the
        /// current subscription.
        /// </summary>
        /// <param name="proxy">
        /// Channel used for communication with Azure's service management APIs.
        /// </param>
        /// <param name="subscriptionId">
        /// The subscription id which contains the server.
        /// </param>
        /// <param name="serverName">
        /// The name of the server for which to reset the password.
        /// </param>
        /// <param name="password">
        /// The new password for the server.
        /// </param>
        public static void SetPassword(this ISqlDatabaseManagement proxy, string subscriptionId, string serverName, string password)
        {
            // create an xml element for the request body
            var xml = string.Empty;

            using (var tx = new StringWriter())
            {
                var tw = new XmlTextWriter(tx);
                tw.WriteStartDocument();
                tw.WriteStartElement("AdministratorLoginPassword", Constants.SqlDatabaseManagementNamespace);
                tw.WriteString(password);
                tw.WriteEndElement();

                xml = tx.ToString();
            }

            var doc = new XmlDocument();

            doc.LoadXml(xml);
            var el = (XmlElement)doc.FirstChild.NextSibling;

            proxy.EndSetPassword(proxy.BeginSetPassword(subscriptionId, serverName, el, null, null));
        }