This samples shows you how to setup an output channel to Azure Blob Storage. You would use this if you needed to output data (like the request or response) in your custom operation.
- Channels can be used as a source or a sink after your input or output filters in the pipeline.
- The Blob Storage channel can only be used as a sink.
- This repository cloned to your machine and an editor (e.g. Visual Studio or Visual Studio Code).
- .NET 8.0 SDK downloaded and installed on your computer.
- An authenticated Azure environment.
- Usually you need to be logged in with the Azure CLI.
- You also can be logged into Azure inside Visual Studio or Visual Studio Code.
- Azure Storage account. Please follow this link for setting up the storage account: Setup Storage Account.
You need to have an Azure subscription with an Azure Storage account and Event Grid to run this sample. Once you have this setup, create a blob container in the storage account. Copy the container name and generate a storage account level connection string. These will need to be added as configuration for the sample. You can configure this either in Visual Studio or by using the command line.
Visual Studio Code / Command Line
Open a terminal or command prompt and navigate to samples\FeatureSamples\BlobChannelSample inside of this repository. Run the below to setup configuration with .NET user secrets.
dotnet user-secrets init
dotnet user-secrets set "ConnectionString" "<<Your Storage Account Connection String>>"
dotnet user-secrets set "Container" "<<Your Storage Account Container Name>>"Visual Studio
You can add this configuration from inside of Visual Studio
-
Open the
BlobChannelSample.slnsolution inside of Visual Studio. -
Right-click on the BlobChannelSample project in the Solution Explorer and choose "Manage User Secrets".
-
An editor for
secrets.jsonwill open. Paste the below inside of this file.{ "ConnectionString": "<Your Storage Account Connection String>", "Container": "<Your Storage Account Container Name>" } -
Save and close
secrets.json.
Visual Studio Code
From Visual Studio, you can click the "Debug" icon on the left and the play button to run and debug this sample.
Visual Studio
The easiest way to run the sample in Visual Studio is to use the debugger by pressing F5 or select "Debug > Start Debugging".
Command Line
From the command line, you can run the sample by executing dotnet run in this directory (samples/FeatureSamples/BlobChannel).
Program.cs: Outlines how you can add configuration for a Blob Channel. There are commends in this file - check it out.PipelineService.cs/IPipelineService.csprovide access to test the web pipeline for the sample.BlobChannelConfig.csis an example configuration for the entire program. It uses the option pattern to provide strongly typed access to groups of related settings. Please refer to this .NET documentation page for more information.RandomString.csprovides some sample data.