public void AzureTableErrorCode_BadTableName() { string tableName = "abc-123"; Assert.Throws <ArgumentException>(() => AzureTableUtils.ValidateTableName(tableName)); }
/// <summary> /// Constructor /// </summary> /// <param name="tableName">Name of the table to be connected to.</param> /// <param name="storageConnectionString">Connection string for the Azure storage account used to host this table.</param> /// <param name="loggerFactory">Logger factory to use.</param> public AzureTableDataManager(string tableName, string storageConnectionString, ILoggerFactory loggerFactory) { Logger = loggerFactory.CreateLogger <AzureTableDataManager <T> >(); TableName = tableName; ConnectionString = storageConnectionString; AzureTableUtils.ValidateTableName(tableName); }
/// <summary> /// Constructor /// </summary> /// <param name="tableName">Name of the table to be connected to.</param> /// <param name="storageConnectionString">Connection string for the Azure storage account used to host this table.</param> /// <param name="logger">Logger to use.</param> public AzureTableDataManager(string tableName, string storageConnectionString, ILogger logger) { Logger = logger; TableName = tableName; ConnectionString = storageConnectionString; AzureTableUtils.ValidateTableName(tableName); }
/// <summary> /// Constructor /// </summary> /// <param name="tableName">Name of the table to be connected to.</param> /// <param name="storageConnectionString">Connection string for the Azure storage account used to host this table.</param> /// <param name="logger">Logger to use.</param> /// <param name="storagePolicyOptions">Optional Storage Policy Configuration.</param> public AzureTableDataManager(string tableName, string storageConnectionString, ILogger logger, AzureStoragePolicyOptions storagePolicyOptions) { Logger = logger ?? throw new ArgumentNullException(nameof(logger)); TableName = tableName ?? throw new ArgumentNullException(nameof(tableName)); ConnectionString = storageConnectionString ?? throw new ArgumentNullException(nameof(storageConnectionString)); this.StoragePolicyOptions = storagePolicyOptions ?? throw new ArgumentNullException(nameof(storagePolicyOptions)); AzureTableUtils.ValidateTableName(tableName); }
/// <summary> /// Constructor /// </summary> /// <param name="tableName">Name of the table to be connected to.</param> /// <param name="storageConnectionString">Connection string for the Azure storage account used to host this table.</param> /// <param name="logger">Logger to use.</param> /// <param name="storagePolicyOptions">Optional Storage Policy Configuration.</param> public AzureTableDataManager(string tableName, string storageConnectionString, ILogger logger, AzureStoragePolicyOptions storagePolicyOptions = default) { Logger = logger; TableName = tableName; ConnectionString = storageConnectionString; AzureTableUtils.ValidateTableName(tableName); this.StoragePolicyOptions ??= storagePolicyOptions; }
/// <summary> /// Creates a new <see cref="AzureTableDataManager{T}"/> instance. /// </summary> /// <param name="options">Storage configuration.</param> /// <param name="logger">Logger to use.</param> public AzureTableDataManager(AzureStorageOperationOptions options, ILogger logger) { this.options = options ?? throw new ArgumentNullException(nameof(options)); Logger = logger ?? throw new ArgumentNullException(nameof(logger)); TableName = options.TableName ?? throw new ArgumentNullException(nameof(options.TableName)); StoragePolicyOptions = options.StoragePolicyOptions ?? throw new ArgumentNullException(nameof(options.StoragePolicyOptions)); AzureTableUtils.ValidateTableName(TableName); }
/// <summary> /// Constructor /// </summary> /// <param name="options">Storage configuration.</param> /// <param name="logger">Logger to use.</param> public AzureTableDataManager(AzureStorageOperationOptions options, ILogger logger) { this.options = options ?? throw new ArgumentNullException(nameof(options)); Logger = logger ?? throw new ArgumentNullException(nameof(logger)); TableName = options.TableName ?? throw new ArgumentNullException(nameof(options.TableName)); StoragePolicyOptions = options.StoragePolicyOptions ?? throw new ArgumentNullException(nameof(options.StoragePolicyOptions)); AzureTableUtils.ValidateTableName(TableName); if (options.TokenCredential != null) { tokenLock = new SemaphoreSlim(1, 1); } }
public void ValidateConfiguration() { if (!CloudStorageAccount.TryParse(this.options.ConnectionString, out var ignore)) { throw new OrleansConfigurationException( $"Configuration for AzureTableStorageProvider {name} is invalid. {nameof(this.options.ConnectionString)} is not valid."); } try { AzureTableUtils.ValidateTableName(this.options.TableName); } catch (Exception e) { throw new OrleansConfigurationException( $"Configuration for AzureTableStorageProvider {name} is invalid. {nameof(this.options.TableName)} is not valid", e); } }
internal void Validate(string name) { if (CreateClient is null) { throw new OrleansConfigurationException($"No credentials specified. Use the {GetType().Name}.{nameof(AzureStorageOperationOptions.ConfigureTableServiceClient)} method to configure the Azure Table Service client."); } try { AzureTableUtils.ValidateTableName(TableName); } catch (Exception ex) { throw GetException($"{nameof(TableName)} is not valid.", ex); } Exception GetException(string message, Exception inner = null) => new OrleansConfigurationException($"Configuration for {GetType().Name} {name} is invalid. {message}", inner); }
public virtual void ValidateConfiguration() { if (Options.TokenCredential != null) { if (Options.TableEndpoint == null) { throw GetException($"{nameof(Options.TableEndpoint)} is required."); } if (string.IsNullOrEmpty(Options.TableResourceId)) { throw GetException($"{nameof(Options.TableResourceId)} is required."); } if (Options.TokenCredentialManagementUri == null) { throw GetException($"{nameof(Options.TokenCredentialManagementUri)} is required."); } } else { if (!CloudStorageAccount.TryParse(Options.ConnectionString, out _)) { throw GetException($"{nameof(Options.ConnectionString)} is not valid."); } } try { AzureTableUtils.ValidateTableName(this.Options.TableName); } catch (Exception ex) { throw GetException($"{nameof(Options.TableName)} is not valid.", ex); } Exception GetException(string message, Exception inner = null) => new OrleansConfigurationException($"Configuration for {GetType().Name} {Name} is invalid. {message}", inner); }