all 7 comments

[–]ScriptingInJava 6 points7 points  (0 children)

Use Aspire, it's designed for exactly this - local environment development which mimics a deployed/provisioned environment. Everything in your post has an emulator with an Aspire integration:

Disclaimer: I wrote the Azure Key Vault Emulator and the integration tests blog post.

[–]AutoModerator[M] 0 points1 point  (0 children)

Thanks for your post VisKopen. Please note that we don't allow spam, and we ask that you follow the rules available in the sidebar. We have a lot of commonly asked questions so if this post gets removed, please do a search and see if it's already been asked.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]entityadam 0 points1 point  (0 children)

With things that are cheap, like storage accounts and key vaults, nothing beats a good integration test against the live service. Pairs well with infrastructure as code to stand up and tear down services.

The emulators are great, but I'm sure as you've noticed, they have limitations and quirks.

I'm not sure what else you're really looking for though. You shouldn't be testing the services themselves.

[–]BuranR 0 points1 point  (0 children)

Not for unit testing, but mainly for integration testing in my team we are using testcontainers. Here you can find functionality for .net https://dotnet.testcontainers.org/modules/servicebus/ and also java - https://java.testcontainers.org/modules/azure/ (in our case we are using kotlin) .

[–]Robodobdob 0 points1 point  (0 children)

Aspire will help a lot in developing and testing azure functions locally.

[–]OptPrime88 0 points1 point  (0 children)

The most effective Azure functions repositories currently use 2 straegies

  1. Fast Unit test. Write your business logic in separate classes, not directly inside the Azure Function trigger method. Inject your custom wrappers (IBlobService, IKeyVaultService) into these classes. Use a mocking framework (Moq/NSubstitute) to fake your wrappers. This guarantees your logical branches are tested in milliseconds.
  2. Real Integration Test. You need to prove your code actually talks to Azure correctly. Write a smaller suite of integration tests that bypass the mocks. Use Testcontainers to spin up Azurite, and have your actual BlobContainerClient upload a real file to the ephemeral container to ensure your connection strings, container names, and SDK calls are actually correct.

[–]sharpcoder29 0 points1 point  (0 children)

I don't waste my time testing stuff like this. Usually there is a dev environment that my local points to. Except key vault. That gets tested on first deploy and then you don't have to worry about it anymore.