Skip to content
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

Support for Azure Functions #97

Merged
merged 6 commits into from
Mar 15, 2019
Merged

Support for Azure Functions #97

merged 6 commits into from
Mar 15, 2019

Conversation

lfalck
Copy link
Contributor

@lfalck lfalck commented Mar 13, 2019

Hi!

Great job with this plugin, really nice!

Like #31 i would like to use it with Azure Functions and it seems like adding plugin support might take a while:

paulbatum commented on Nov 7, 2018
There are no updates for this. It is not tracked as a high priority issue at this time.

Therefore i added these extensions to Message as a temporary solution. Usage looks something like this:

Sending

var config = new AzureStorageAttachmentConfiguration(storageConnectionString);
var message = new Message(data);
return await message.UploadAzureStorageAttachment(config);

Receiving

await message.DownloadAzureStorageAttachment(config);
string body = System.Text.Encoding.UTF8.GetString(message.Body);

Here is a full example with Azure functions sending and receiving from Service Bus.

What do you think?

@lfalck lfalck requested a review from SeanFeldman as a code owner March 13, 2019 09:00
@SeanFeldman
Copy link
Owner

@SeanFeldman
Copy link
Owner

Thank you @lfalck.

It's a shame Functions team doesn't consider support for the plugins. There are other things that people as for, such as Sessions support, that is still not available. Sooner or later it will arrive, but for now it seems that a manual approach is the only options.

Looking at the PR there are a few things I can think of.

  1. DownloadAzureStorageAttachment() is relying on a configuration that using connection string. Internally, it's always using AzureStorageAttachment. But there's also an option to use the plugin and RegisterAzureStorageAttachmentPluginForReceivingOnly(), which is using ReceiveOnlyAzureStorageAttachment behind the schenes. I can see the second option be even more popular for the Functions that respond to 3rd party messages and don't have access to the Storage account via connection string or SAS token.
  2. This functionality is going to be temporary until Functions runtime adds support for ASB plugins.
  3. The plugin in the extension methods is going to be re-created each time a function is invoked. While there's no big overhead, the question is should those allocation be avoided or not. And if the answer is "yes", does that mean the plugin has to inspect the configuration object and cache plugin instances using configuration object (with it's values) as a key? Or is this an unnecessary optimization?

Let's answer these and see if there's anything else that needs to be done. Overall, adding support for Functions is likely to be a welcomed feature 👍

@SeanFeldman
Copy link
Owner

@SeanFeldman
Copy link
Owner

@SeanFeldman
Copy link
Owner

@lfalck
Copy link
Contributor Author

lfalck commented Mar 14, 2019

  1. Great input! I added two overloads to DownloadAzureStorageAttachment(), one without parameters which uses DefaultMessagePropertyToIdentitySasUri and one where you can specify a custom property.
  2. Agreed!
  3. Compared to the communication with service bus and storage, creating an extra object should not be noticeable, right?

Yeah it would be really nice!

Copy link
Owner

@SeanFeldman SeanFeldman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more change and can be merged.

src/ServiceBus.AttachmentPlugin/MessageExtensions.cs Outdated Show resolved Hide resolved
src/ServiceBus.AttachmentPlugin/MessageExtensions.cs Outdated Show resolved Hide resolved
@SeanFeldman SeanFeldman changed the title Working with attachments without registering plugin for use with e.g. Azure Functions Support for Azure Functions Mar 15, 2019
@SeanFeldman SeanFeldman added this to the 4.2.0 milestone Mar 15, 2019
@SeanFeldman
Copy link
Owner

Compared to the communication with service bus and storage, creating an extra object should not be noticeable, right?

Probably two different dimensions - latency vs memory allocation/GC. Probably not worth looking into it until there's a strong evidence that there's a problem.

Once you update you PR with the request change, I'll release 4.2.0.

README.source.md would need to be updated to include a section for Azure functinos with sending/receiving snippets. The best use-case to talk about I can think of is when an Azure Function has to respond to ASB messages (receive) with attachments.

@SeanFeldman
Copy link
Owner

@lfalck
Copy link
Contributor Author

lfalck commented Mar 15, 2019

Probably two different dimensions - latency vs memory allocation/GC. Probably not worth looking into it until there's a strong evidence that there's a problem.

Yeah you are right, hopefully it won't be a problem.

README.source.md would need to be updated to include a section for Azure functinos with sending/receiving snippets. The best use-case to talk about I can think of is when an Azure Function has to respond to ASB messages (receive) with attachments.

I gave a shot at updating the README, feel free to change as needed.

Once you update you PR with the request change, I'll release 4.2.0.

Great! 👍

@SeanFeldman
Copy link
Owner

@SeanFeldman SeanFeldman merged commit aea27fd into SeanFeldman:develop Mar 15, 2019
@SeanFeldman
Copy link
Owner

Thank you @lfalck
I'm sure many will be happy to see this addition while the jury is still out on Azure/azure-functions-host#2504

@lfalck
Copy link
Contributor Author

lfalck commented Mar 15, 2019

Thank you @SeanFeldman for creating this plugin! 👍

@SeanFeldman SeanFeldman modified the milestones: 4.2.0, 5.0.0 Mar 15, 2019
@SeanFeldman
Copy link
Owner

@lfalck could you please share your twitter account with me to give you the credit? Thanks.

@lfalck
Copy link
Contributor Author

lfalck commented Mar 15, 2019

@SeanFeldman Thanks! It is ludvigfalck

@SeanFeldman SeanFeldman mentioned this pull request Mar 15, 2019
@jstclair
Copy link

Great timing! I've done something similar, but rather than write extension methods off message, I'd just copied some of the underlying implementation into our (receiving) functions.

Sean, now that Azure Functions supports user-extensible triggers, how would feel about taking/creating a sub-project to extend the existing ServiceBus(x)Trigger with the attachments plugin support? Here's an example on extending the existing Cosmos trigger to support POCOs

@SeanFeldman
Copy link
Owner

@jstclair I've raised #101 for this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants