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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MockResponse.Middleware.Azure.BlobStorage" Version="8.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MockResponse.Middleware.Azure.BlobStorage" Version="8.0.1" />
                    
Directory.Packages.props
<PackageReference Include="MockResponse.Middleware.Azure.BlobStorage" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MockResponse.Middleware.Azure.BlobStorage --version 8.0.1
                    
#r "nuget: MockResponse.Middleware.Azure.BlobStorage, 8.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MockResponse.Middleware.Azure.BlobStorage@8.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MockResponse.Middleware.Azure.BlobStorage&version=8.0.1
                    
Install as a Cake Addin
#tool nuget:?package=MockResponse.Middleware.Azure.BlobStorage&version=8.0.1
                    
Install as a Cake Tool

<a id="readme-top"></a>

MockResponse.Middleware.Azure.BlobStorage

.NET License

CI/CD Pipeline CodeQL NuGet - Azure Blob Storage

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

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.

  1. Initialize Secrets Manager for your project (if not already initialized):
dotnet user-secrets init
  1. 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.

  1. 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 the subfolder 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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