public async Task <int> UpdateAzureDevOpsBuilds( string organization, string project, string repository, string branch, string buildName, string buildId, int numberOfDays, int maxNumberOfItems) { int numberOfRecordsSaved; try { TableStorageConfiguration tableStorageConfig = Common.GenerateTableStorageConfiguration(Configuration); //Get the PAT token from the key vault string patTokenName = PartitionKeys.CreateAzureDevOpsSettingsPartitionKeyPatToken(organization, project, repository); patTokenName = SecretsProcessing.CleanKey(patTokenName); string patToken = Configuration[patTokenName]; if (string.IsNullOrEmpty(patToken) == true) { throw new Exception($"patToken '{patTokenName}' not found in key vault"); } numberOfRecordsSaved = await AzureTableStorageDA.UpdateAzureDevOpsBuildsInStorage(patToken, tableStorageConfig, organization, project, branch, buildName, buildId, numberOfDays, maxNumberOfItems); } catch (Exception ex) { if (ex.Message == "Response status code does not indicate success: 403 (rate limit exceeded).") { numberOfRecordsSaved = -1; } else { throw; } } return(numberOfRecordsSaved); }
public void TestStart() { //Arrange Dictionary <string, string> inMemorySettings = new() { { "AppSettings:KeyVaultURL", "keyvaultURLTest" }, { PartitionKeys.CreateAzureDevOpsSettingsPartitionKeyPatToken("", "", ""), "patTokenSecret" },
public async Task <bool> UpdateAzureDevOpsSetting(string patToken, string organization, string project, string repository, string branch, string buildName, string buildId, string resourceGroup, int itemOrder, bool showSetting) { //Save the PAT token to the key vault string patTokenName = PartitionKeys.CreateAzureDevOpsSettingsPartitionKeyPatToken(organization, project, repository); patTokenName = SecretsProcessing.CleanKey(patTokenName); if (patTokenName.Length > 12) { await CreateKeyVaultSecret(patTokenName, patToken); } //Save everything else to table storage TableStorageConfiguration tableStorageConfig = Common.GenerateTableStorageConfiguration(Configuration); return(await AzureTableStorageDA.UpdateAzureDevOpsSettingInStorage(tableStorageConfig, tableStorageConfig.TableAzureDevOpsSettings, organization, project, repository, branch, buildName, buildId, resourceGroup, itemOrder, showSetting)); }
public async Task<LeadTimeForChangesModel> GetAzureDevOpsLeadTimeForChanges(bool getSampleData, string organization, string project, string repository, string branch, string buildName, int numberOfDays, int maxNumberOfItems, bool useCache) { LeadTimeForChangesModel model = new(); try { TableStorageConfiguration tableStorageConfig = Common.GenerateTableStorageConfiguration(Configuration); //Get the PAT token from the key vault string patTokenName = PartitionKeys.CreateAzureDevOpsSettingsPartitionKeyPatToken(organization, project, repository); patTokenName = SecretsProcessing.CleanKey(patTokenName); string patToken = Configuration[patTokenName]; if (string.IsNullOrEmpty(patToken) == true) { throw new Exception($"patToken '{patTokenName}' not found in key vault"); } LeadTimeForChangesDA da = new(); model = await da.GetAzureDevOpsLeadTimesForChanges(getSampleData, patToken, tableStorageConfig, organization, project, repository, branch, buildName, numberOfDays, maxNumberOfItems, useCache); } catch (Exception ex) { if (ex.Message == "Response status code does not indicate success: 403 (rate limit exceeded).") { model.ProjectName = project; model.RateLimitHit = true; } else { throw; } } return model; }