From 2f47d7d01513acded6e3578100d085c382dcf6fb Mon Sep 17 00:00:00 2001 From: Marc Duiker Date: Fri, 19 Apr 2019 14:09:26 +0200 Subject: [PATCH 1/3] Fixed incorrect tablename --- .../Publications/GetLatestPublicationFromHistory.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AzureFunctionsUpdates/Activities/Publications/GetLatestPublicationFromHistory.cs b/src/AzureFunctionsUpdates/Activities/Publications/GetLatestPublicationFromHistory.cs index 412f4f3..dc4da9f 100644 --- a/src/AzureFunctionsUpdates/Activities/Publications/GetLatestPublicationFromHistory.cs +++ b/src/AzureFunctionsUpdates/Activities/Publications/GetLatestPublicationFromHistory.cs @@ -14,12 +14,12 @@ public class GetLatestPublicationFromHistory [StorageAccount(Configuration.ConnectionName)] public async Task Run( [ActivityTrigger] PublicationConfiguration publicationConfiguration, - [Table(Configuration.Releases.TableName)] CloudTable table, + [Table(Configuration.Publications.TableName)] CloudTable table, ILogger logger) { logger.LogInformation($"Started {nameof(GetLatestPublicationFromHistory)} for { publicationConfiguration.PublicationSourceOwner } { publicationConfiguration.PublicationSourceName }."); - Publication latestKnownPublication = null; + Publication latestKnownPublication = null; var query = QueryBuilder.CreateQueryForPartitionKey(publicationConfiguration.PublicationSourceName); var queryResult = await table.ExecuteQuerySegmentedAsync(query, null); latestKnownPublication = queryResult.Results.AsReadOnly().OrderByDescending(publication => publication.PublicationDate).FirstOrDefault(); From 3554b49c87860678d7f59f17880e950e491eeb78 Mon Sep 17 00:00:00 2001 From: Marc Duiker Date: Fri, 19 Apr 2019 14:09:46 +0200 Subject: [PATCH 2/3] Added logging when release is found --- .../RepositoryReleases/GetLatestReleaseFromHistory.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/AzureFunctionsUpdates/Activities/RepositoryReleases/GetLatestReleaseFromHistory.cs b/src/AzureFunctionsUpdates/Activities/RepositoryReleases/GetLatestReleaseFromHistory.cs index 3f18508..ad799d6 100644 --- a/src/AzureFunctionsUpdates/Activities/RepositoryReleases/GetLatestReleaseFromHistory.cs +++ b/src/AzureFunctionsUpdates/Activities/RepositoryReleases/GetLatestReleaseFromHistory.cs @@ -19,11 +19,18 @@ public async Task Run( { logger.LogInformation($"Started {nameof(GetLatestReleaseFromHistory)} for { repoConfiguration.RepositoryOwner } { repoConfiguration.RepositoryName }."); - RepositoryRelease latestKnownRelease = null; + RepositoryRelease latestKnownRelease = null; var query = QueryBuilder.CreateQueryForPartitionKey(repoConfiguration.RepositoryName); var queryResult = await table.ExecuteQuerySegmentedAsync(query, null); latestKnownRelease = queryResult.Results.AsReadOnly().OrderByDescending(release => release.CreatedAt).FirstOrDefault(); - + + if (latestKnownRelease != null) + { + logger.LogInformation($"Found release in history for configuration: {repoConfiguration.RepositoryName}, " + + $"Release ID: {latestKnownRelease.ReleaseId}," + + $"ReleaseCreatedAt: {latestKnownRelease.ReleaseCreatedAt:F}."); + } + return latestKnownRelease ?? new NullRelease(repoConfiguration.RepositoryName); } } From 8d6b10f73e7cc5c5d117d443ec1e18ea642db1a5 Mon Sep 17 00:00:00 2001 From: Marc Duiker Date: Fri, 19 Apr 2019 14:10:09 +0200 Subject: [PATCH 3/3] Ensured partitionKey is sanitized when used in query --- src/AzureFunctionsUpdates/Storage/QueryBuilder.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/AzureFunctionsUpdates/Storage/QueryBuilder.cs b/src/AzureFunctionsUpdates/Storage/QueryBuilder.cs index 43ddf1e..b9ce868 100644 --- a/src/AzureFunctionsUpdates/Storage/QueryBuilder.cs +++ b/src/AzureFunctionsUpdates/Storage/QueryBuilder.cs @@ -6,8 +6,9 @@ namespace AzureFunctionsUpdates.Storage { public static TableQuery CreateQueryForPartitionKey(string partitionKey) { + var sanitizedPartitionKey = KeyFormatter.SanitizeKey(partitionKey); return new TableQuery() - .Where(GetFilterConditionWhichEqualsPartitionKey(partitionKey)); + .Where(GetFilterConditionWhichEqualsPartitionKey(sanitizedPartitionKey)); } private static string GetFilterConditionWhichEqualsPartitionKey(string partitionKey)