Example #1
0
 public AzureStorageConnectionString(TokenCredentialProvider tokenCredentialProvider, ISystemClock clock)
 {
     _tokenCredentialProvider = tokenCredentialProvider;
     _clock = clock;
 }
Example #2
0
 public AzureKeyVault(TokenCredentialProvider tokenCredentialProvider)
 {
     _tokenCredentialProvider = tokenCredentialProvider;
 }
Example #3
0
 public AzureKeyVault(IReadOnlyDictionary <string, string> parameters, TokenCredentialProvider tokenCredentialProvider) : base(parameters)
 {
     _tokenCredentialProvider = tokenCredentialProvider;
     ReadRequiredParameter("subscription", ref _subscription);
     ReadRequiredParameter("name", ref _vaultName);
 }
 public AzureStorageKey(TokenCredentialProvider tokenCredentialProvider, ISystemClock clock)
 {
     _tokenCredentialProvider = tokenCredentialProvider;
     _clock = clock;
 }
Example #5
0
 public TestCommand(IConsole console, TokenCredentialProvider tokenProvider)
 {
     _console       = console;
     _tokenProvider = tokenProvider;
 }
 public ServiceBusConnectionString(TokenCredentialProvider tokenCredentialProvider, ISystemClock clock)
 {
     _tokenCredentialProvider = tokenCredentialProvider;
     _clock = clock;
 }
Example #7
0
 public EventHubConnectionString(TokenCredentialProvider tokenCredentialProvider, ISystemClock clock)
 {
     _tokenCredentialProvider = tokenCredentialProvider;
     _clock = clock;
 }
Example #8
0
        public static async Task <string> RotateStorageAccountKey(string subscriptionId, string accountName, RotationContext context, TokenCredentialProvider tokenCredentialProvider, CancellationToken cancellationToken)
        {
            StorageManagementClient client = await CreateManagementClient(subscriptionId, tokenCredentialProvider, cancellationToken);

            StorageAccount account = await FindAccount(accountName, client, cancellationToken);

            if (account == null)
            {
                throw new ArgumentException($"Storage account '{accountName}' in subscription '{subscriptionId}' not found.");
            }

            string     currentKey = context.GetValue("currentKey", "key1");
            ResourceId id         = ResourceId.FromString(account.Id);
            StorageAccountListKeysResult keys;
            string keyToReturn;

            switch (currentKey)
            {
            case "key1":
                keys = await client.StorageAccounts.RegenerateKeyAsync(id.ResourceGroupName, id.Name, "key2", cancellationToken : cancellationToken);

                keyToReturn = "key2";
                break;

            case "key2":
                keys = await client.StorageAccounts.RegenerateKeyAsync(id.ResourceGroupName, id.Name, "key1", cancellationToken : cancellationToken);

                keyToReturn = "key1";
                break;

            default:
                throw new InvalidOperationException($"Unexpected 'currentKey' value '{currentKey}'.");
            }

            StorageAccountKey key = keys.Keys.FirstOrDefault(k => k.KeyName == keyToReturn) ?? throw new InvalidOperationException($"Key {keyToReturn} not found.");

            context.SetValue("currentKey", keyToReturn);

            return(key.Value);
        }
Example #9
0
 public AzureStorageConnectionString(IReadOnlyDictionary <string, string> parameters, TokenCredentialProvider tokenCredentialProvider) : base(parameters)
 {
     _tokenCredentialProvider = tokenCredentialProvider;
     ReadRequiredParameter("subscription", ref _subscription);
     ReadRequiredParameter("account", ref _accountName);
 }