MockResponse.Middleware.Azure.BlobStorage
8.0.1
dotnet add package MockResponse.Middleware.Azure.BlobStorage --version 8.0.1
NuGet\Install-Package MockResponse.Middleware.Azure.BlobStorage -Version 8.0.1
<PackageReference Include="MockResponse.Middleware.Azure.BlobStorage" Version="8.0.1" />
<PackageVersion Include="MockResponse.Middleware.Azure.BlobStorage" Version="8.0.1" />
<PackageReference Include="MockResponse.Middleware.Azure.BlobStorage" />
paket add MockResponse.Middleware.Azure.BlobStorage --version 8.0.1
#r "nuget: MockResponse.Middleware.Azure.BlobStorage, 8.0.1"
#:package MockResponse.Middleware.Azure.BlobStorage@8.0.1
#addin nuget:?package=MockResponse.Middleware.Azure.BlobStorage&version=8.0.1
#tool nuget:?package=MockResponse.Middleware.Azure.BlobStorage&version=8.0.1
<a id="readme-top"></a>
MockResponse.Middleware.Azure.BlobStorage
This package provides an Azure Blob Storage-backed provider for use with the MockResponse.Middleware
system. It enables serving mock API responses from Azure Blob Storage, ideal for testing and shared development environments where cloud-based access is still needed.
Table of Contents
- Installation
- Configuration
- BlobStorageOptions Configuration
- Usage: AddAzureBlobStorage
- Troubleshooting
๐ฆ Installation
dotnet add package MockResponse.Middleware.Azure.BlobStorage
<p align="right">(<a href="#readme-top">back to top</a>)</p>
โ๏ธ Configuration
Configure the Azure Blob Storage provider using Microsoft Secret Manager to avoid storing sensitive information in plain text files.
- Initialize Secrets Manager for your project (if not already initialized):
dotnet user-secrets init
- Add your Azure Blob Storage settings:
dotnet user-secrets set "MockOptions:BlobStorageOptions:ConnectionString" "<your-connection-string>"
dotnet user-secrets set "MockOptions:BlobStorageOptions:ContainerName" "<your-container-name>"
These values are securely stored in your local secrets store and accessed via IConfiguration
at runtime.
- Add additional mock configuration properties to your
appsettings.json
:
{
"MockOptions": {
"ExcludedRequestPaths": ["/api/health", "/openapi", "/metrics", "/redoc", "/swagger"],
"ResponseMappings": {
"Namespace.TypeName": "ExampleResponse.json",
"Namespace.TypeName.Variant": "subfolder/ExampleResponse.Variant.json"
},
"UseMock": true
}
}
๐ก Azure Blob Storage supports virtual folders by including
/
in blob names.For example,
"subfolder/ExampleResponse.Variant.json"
will correctly resolve and retrieve the mock from thesubfolder
virtual directory.
<p align="right">(<a href="#readme-top">back to top</a>)</p>
๐ง BlobStorageOptions Configuration
The following configuration properties are used by the Azure Blob Storage mock provider. These settings are nested under MockOptions:BlobStorageOptions
.
Property | Type | Required | Description |
---|---|---|---|
ConnectionString |
string |
โ | Azure Blob Storage connection string with permission to read blobs from the configured container. |
ContainerName |
string |
โ | The name of the container where mock JSON files are stored. |
๐ These values should be stored in user secrets or injected securely via environment variables or Key Vault.
<p align="right">(<a href="#readme-top">back to top</a>)</p>
๐ Usage: AddAzureBlobStorage
Register the middleware in Startup.cs
or Program.cs
:
services.AddApiMocking(Configuration)
.AddAzureBlobStorage();
Use the middleware:
app.UseApiMocking();
<p align="right">(<a href="#readme-top">back to top</a>)</p>
๐งช Troubleshooting
Missing Configurations
โ ๏ธ Missing ConnectionString
Error Message
AzureBlobStorageOptions.ConnectionString must not be null or empty.
Cause
The ConnectionString
was not provided in MockOptions:BlobStorageOptions
, or it wasn't loaded via configuration (e.g. missing from secrets or environment).
Solution
Set the connection string securely via User Secrets, environment variables, or other config providers:
dotnet user-secrets set "MockOptions:BlobStorageOptions:ConnectionString" "<your-connection-string>"
โ ๏ธ Missing ContainerName
Error Message
AzureBlobStorageOptions.ContainerName must not be null or empty.
Cause
The ContainerName
was not provided in MockOptions:BlobStorageOptions
, or it wasn't loaded via configuration (e.g. missing from secrets or environment).
Solution
Set the container name securely via User Secrets, environment variables, or other config providers:
dotnet user-secrets set "MockOptions:BlobStorageOptions:ContainerName" "<your-container-name>"
Runtime Errors
โ ๏ธ Blob container not found
Error Message
The specified container does not exist.
Cause
The ContainerName
is incorrect, or the specified container does not exist in the configured Azure Storage account.
Solution
Double-check the ContainerName
setting, verify that the container exists in your Azure Storage account, and the correct permissions are configured for the storage account.
๐ Ensure the storage account connection string has read permissions to the container. This is typically required if using a shared access key or managed identity.
๐ For additional error handling scenarios, see the Core Troubleshooting Guide.
<p align="right">(<a href="#readme-top">back to top</a>)</p>
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Azure.Storage.Blobs (>= 12.24.1)
- MockResponse.Middleware.Core (>= 8.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
8.0.1 | 86 | 7/29/2025 |
8.0.1-preview | 112 | 6/26/2025 |