/// <summary> /// Initializes a new instance of the <see cref="TokenCloudCredentials"/> /// class without subscription ID. /// </summary> /// <param name="token">Valid JSON Web Token (JWT).</param> public TokenCloudCredentials(string token) { if (token == null) { throw new ArgumentNullException("token"); } else if (token.Length == 0) { throw CloudExtensions.CreateArgumentEmptyException("token"); } Token = token; }
/// <summary> /// Initializes a new instance of the CertificateCloudCredentials /// class. /// </summary> /// <param name="subscriptionId">The Subscription ID.</param> public CertificateCloudCredentials(string subscriptionId) { if (subscriptionId == null) { throw new ArgumentNullException("subscriptionId"); } else if (subscriptionId.Length == 0) { throw CloudExtensions.CreateArgumentEmptyException("subscriptionId"); } _subscriptionId = subscriptionId; }
public IDictionary <string, object> Parse(string settings) { if (settings == null) { throw new ArgumentNullException("settings"); } else if (settings.Length == 0) { throw CloudExtensions.CreateArgumentEmptyException("settings"); } return(JsonConvert.DeserializeObject <Dictionary <string, object> >(settings)); }
/// <summary> /// Parse a JSON settings file. /// </summary> /// <param name="settings">The JSON settings.</param> /// <returns> /// A dictionary of the setting names and values from the JSON /// settings. /// </returns> public IDictionary <string, object> ParseJsonSettings(string settings) { if (settings == null) { throw new ArgumentNullException("settings"); } else if (settings.Length == 0) { throw CloudExtensions.CreateArgumentEmptyException("settings"); } return(new JsonSettingsFormat().Parse(settings)); }
/// <summary> /// Parse a connection string. /// </summary> /// <param name="connectionString">The connection string.</param> /// <returns> /// A dictionary of the setting names and values from the connection /// string. /// </returns> public IDictionary <string, object> ParseConnectionStringSettings(string connectionString) { if (connectionString == null) { throw new ArgumentNullException("connectionString"); } else if (connectionString.Length == 0) { throw CloudExtensions.CreateArgumentEmptyException("connectionString"); } return(new ConnectionStringSettingsFormat().Parse(connectionString)); }
/// <summary> /// Get the value of a configuration setting from a platform specific /// configuration source. /// </summary> /// <param name="name">The name of the setting.</param> /// <returns>The value of the setting, or null if not found.</returns> public string GetSetting(string name) { if (name == null) { throw new ArgumentNullException("name"); } else if (name.Length == 0) { throw CloudExtensions.CreateArgumentEmptyException("name"); } return(ConfigurationProvider.GetSetting(name)); }
/// <summary> /// Creates a new server in the current subscription. /// </summary> /// <param name="adminLogin"> /// The administrator login name for the new server. /// </param> /// <param name="adminLoginPassword"> /// The administrator login password for the new server. /// </param> /// <param name="location"> /// The location in which to create the new server. /// </param> /// <returns>The context to the newly created server.</returns> internal SqlDatabaseServerContext NewAzureSqlDatabaseServerProcess( string adminLogin, string adminLoginPassword, string location, float?version) { // Do nothing if force is not specified and user cancelled the operation if (!Force.IsPresent && !ShouldProcess( Resources.NewAzureSqlDatabaseServerDescription, Resources.NewAzureSqlDatabaseServerWarning, Resources.ShouldProcessCaption)) { return(null); } // Get the SQL management client for the current subscription SqlManagementClient sqlManagementClient = GetCurrentSqlClient(); // Set the retry policty to not retry attempts. CloudExtensions.SetRetryPolicy <SqlManagementClient>( sqlManagementClient, new WindowsAzure.Common.TransientFaultHandling.RetryPolicy(new WindowsAzure.Common.TransientFaultHandling.DefaultHttpErrorDetectionStrategy(), 0)); // Issue the create server request ServerCreateResponse response = sqlManagementClient.Servers.Create( new ServerCreateParameters() { Location = location, AdministratorUserName = adminLogin, AdministratorPassword = adminLoginPassword, Version = version.HasValue ? version.Value.ToString("F1") : null }); SqlDatabaseServerContext operationContext = new SqlDatabaseServerContext() { OperationStatus = Services.Constants.OperationSuccess, OperationDescription = CommandRuntime.ToString(), OperationId = response.RequestId, ServerName = response.ServerName, Location = location, AdministratorLogin = adminLogin, }; return(operationContext); }
/// <summary> /// Initializes a new instance of the CertificateCloudCredentials /// class. /// </summary> /// <param name="subscriptionId">The Subscription ID.</param> /// <param name="managementCertificate"> /// The management certificate. /// </param> public CertificateCloudCredentials(string subscriptionId, X509Certificate2 managementCertificate) { if (subscriptionId == null) { throw new ArgumentNullException("subscriptionId"); } else if (subscriptionId.Length == 0) { throw CloudExtensions.CreateArgumentEmptyException("subscriptionId"); } else if (managementCertificate == null) { throw new ArgumentNullException("managementCertificate"); } _subscriptionId = subscriptionId; ManagementCertificate = managementCertificate; }
public IDictionary<string,object> Parse(string settings) { if (settings == null) { throw new ArgumentNullException("settings"); } else if (settings.Length == 0) { throw CloudExtensions.CreateArgumentEmptyException("settings"); } IDictionary<string, object> parameters = new Dictionary<string, object>(); foreach (KeyValuePair<string, string> setting in ConnectionStringParser.Parse(settings)) { parameters[setting.Key] = setting.Value; } return parameters; }
/// <summary> /// Get named connection info that can be used to instantiate a type by /// searching for configuration settings of the format /// Namespace.Type.Name.format. If no connection info is found for /// the type, we will search for connection info for all of its base /// types. /// </summary> /// <param name="type"> /// The type to obtain connection info for. /// </param> /// <param name="name">The name of the connection info.</param> /// <returns> /// Connection info used to instantiate the given type or null if /// no connection string is found. /// </returns> /// <remarks> /// You can get insight into the connection info search by checking /// the tracing output. /// </remarks> public IDictionary <string, object> GetConnectionInfo(Type type, string name) { if (type == null) { throw new ArgumentNullException("type"); } else if (name == null) { throw new ArgumentNullException("name"); } else if (name.Length == 0) { throw CloudExtensions.CreateArgumentEmptyException("name"); } string key = null; string value = null; return(ProbeForConnectionInfo(type, name, out key, out value)); }
/// <summary> /// Initializes a new instance of the <see cref="TokenCloudCredentials"/> /// class with subscription ID. /// </summary> /// <param name="subscriptionId">The Subscription ID.</param> /// <param name="token">Valid JSON Web Token (JWT).</param> public TokenCloudCredentials(string subscriptionId, string token) { if (subscriptionId == null) { throw new ArgumentNullException("subscriptionId"); } else if (subscriptionId.Length == 0) { throw CloudExtensions.CreateArgumentEmptyException("subscriptionId"); } else if (token == null) { throw new ArgumentNullException("token"); } else if (token.Length == 0) { throw CloudExtensions.CreateArgumentEmptyException("token"); } _subscriptionId = subscriptionId; Token = token; }