-
Notifications
You must be signed in to change notification settings - Fork 295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Store absolute blob URIs instead of just the blob name #929
base: main
Are you sure you want to change the base?
Changes from all commits
b1841a8
bff76fc
6b1269a
c428895
1b27aee
2f936ac
5ac3375
eb87e7e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1127,7 +1127,17 @@ public override async Task<string> UpdateStateAsync( | |
var tasks = new List<Task>(blobsToDelete.Count); | ||
foreach (var blobName in blobsToDelete) | ||
{ | ||
tasks.Add(this.messageManager.DeleteBlobAsync(blobName)); | ||
Task task; | ||
if (Uri.TryCreate(blobName, UriKind.Absolute, out Uri blobUri)) | ||
{ | ||
task = this.messageManager.DeleteBlobAsync(blobUri); | ||
} | ||
else | ||
{ | ||
// backwards compatibility path: construct blob URI from blob name and delete | ||
task = this.messageManager.DeleteBlobAsync(blobName); | ||
} | ||
tasks.Add(task); | ||
} | ||
await Task.WhenAll(tasks); | ||
} | ||
|
@@ -1190,8 +1200,21 @@ void SetInstancesTablePropertyFromHistoryProperty( | |
if (historyEntity.Properties.TryGetValue(blobPropertyName, out EntityProperty blobProperty)) | ||
{ | ||
// This is a large message | ||
string blobName = blobProperty.StringValue; | ||
string blobUrl = this.messageManager.GetBlobUrl(blobName); | ||
string blobData = blobProperty.StringValue; | ||
|
||
// We now store blobs as absolute URIs to minimize chance of 'blob not found' errors | ||
// For backwards compatibility to versions where we only stored the blobname, we check if the blob is a URI | ||
string blobUrl; | ||
if (!Uri.TryCreate(blobData, UriKind.Absolute, out Uri _)) | ||
{ | ||
// backwards compatibility path: we construct the URL from the blobName | ||
blobUrl = this.messageManager.GetBlobUrl(blobData); | ||
} | ||
else | ||
{ | ||
blobUrl = blobData; | ||
} | ||
|
||
instanceEntity.Properties[instancePropertyName] = new EntityProperty(blobUrl); | ||
} | ||
else | ||
|
@@ -1216,7 +1239,10 @@ async Task CompressLargeMessageAsync(DynamicTableEntity entity, List<string> lis | |
// Clear out the original property value and create a new "*BlobName"-suffixed property. | ||
// The runtime will look for the new "*BlobName"-suffixed column to know if a property is stored in a blob. | ||
string blobPropertyName = GetBlobPropertyName(propertyName); | ||
entity.Properties.Add(blobPropertyName, new EntityProperty(blobName)); | ||
|
||
// Store blob URL so the blob can always be downloaded from the absolute path | ||
string bloburl = this.messageManager.GetBlobUrl(blobName); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. C# naming nit: should be |
||
entity.Properties.Add(blobPropertyName, new EntityProperty(bloburl)); | ||
entity.Properties[propertyName].StringValue = string.Empty; | ||
|
||
// if necessary, keep track of all the blobs associated with this execution | ||
|
@@ -1234,7 +1260,19 @@ async Task DecompressLargeEntityProperties(DynamicTableEntity entity, List<strin | |
if (entity.Properties.TryGetValue(blobPropertyName, out EntityProperty property)) | ||
{ | ||
string blobName = property.StringValue; | ||
string decompressedMessage = await this.messageManager.DownloadAndDecompressAsBytesAsync(blobName); | ||
|
||
// We now store blob URIs instead of just blob names to prevent blob not found errors | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment about making the code comment more specific. I think the important point here is that older versions store just the blob name, but newer versions store blobs as full URLs. I don't think it's necessary to talk about "blob not found" here because that assumes very specific context of a bug fix which future maintainers won't know about. |
||
string decompressedMessage; | ||
if (Uri.TryCreate(blobName, UriKind.Absolute, out Uri blobUri)) | ||
{ | ||
decompressedMessage = await this.messageManager.DownloadAndDecompressAsBytesAsync(blobUri); | ||
} | ||
else | ||
{ | ||
// backwards compatibility path: construct blob URI from blob name and download | ||
decompressedMessage = await this.messageManager.DownloadAndDecompressAsBytesAsync(blobName); | ||
} | ||
|
||
entity.Properties[propertyName] = new EntityProperty(decompressedMessage); | ||
entity.Properties.Remove(blobPropertyName); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is too vague. I think it needs to be more specific to help future maintainers understand the implications: