Build and test a minimal App
This complete App adds a prefix to text. It makes no provider requests and needs no credentials, so you can test the SDK structure before adding an integration.
Project and implementation
Section titled “Project and implementation”Create the Setup project using .NET 8 and Blackbird.Applications.Sdk.Common 2.17.0. Replace the generated Class1.cs with this file:
using Blackbird.Applications.Sdk.Common;using Blackbird.Applications.Sdk.Common.Actions;using Blackbird.Applications.Sdk.Common.Authentication;using Blackbird.Applications.Sdk.Common.Connections;using Blackbird.Applications.Sdk.Common.Invocation;
namespace Apps.MinimalExample;
public class Application : IApplication{ public T GetInstance<T>() => throw new NotSupportedException($"This App does not register {typeof(T).Name}.");}
public class ConnectionDefinition : IConnectionDefinition{ public IEnumerable<ConnectionPropertyGroup> ConnectionPropertyGroups => [];
public IEnumerable<AuthenticationCredentialsProvider> CreateAuthorizationCredentialsProviders( Dictionary<string, string> values) => [];}
public class ConnectionValidator : IConnectionValidator{ public ValueTask<ConnectionValidationResponse> ValidateConnection( IEnumerable<AuthenticationCredentialsProvider> credentials, CancellationToken cancellationToken) => ValueTask.FromResult(new ConnectionValidationResponse { IsValid = true });}
[ActionList]public class TextActions : BaseInvocable{ public TextActions(InvocationContext context) : base(context) { }
[Action("Prefix text", Description = "Add an optional prefix to text")] public TextResult PrefixText([ActionParameter] TextInput input) { InvocationContext.Logger?.LogInformation?.Invoke("Prefix text completed.", []); return new TextResult { Text = (input.Prefix ?? string.Empty) + input.Text }; }}
public class TextInput{ [Display("Text")] public string Text { get; set; } = string.Empty; [Display("Prefix")] public string? Prefix { get; set; }}
public class TextResult{ [Display("Text")] public string Text { get; set; } = string.Empty;}The empty connection definition is intentional for this credential-free App. A real content service needs the authenticated definition and validator from Connections. IApplication.GetInstance<T>() supplies App services such as OAuth implementations when they are registered; this example has none.
Local testing
Section titled “Local testing”Create a console project next to the App project and add a reference to it:
dotnet new console --name AppSmoke --framework net8.0dotnet add AppSmoke/AppSmoke.csproj reference Apps.YourApp/Apps.YourApp.csprojReplace AppSmoke/Program.cs with this code, then run dotnet run --project AppSmoke:
using Apps.MinimalExample;using Blackbird.Applications.Sdk.Common.Authentication;using Blackbird.Applications.Sdk.Common.Invocation;
var context = new InvocationContext{ AuthenticationCredentialsProviders = Array.Empty<AuthenticationCredentialsProvider>()};var actions = new TextActions(context);var result = actions.PrefixText(new TextInput { Text = "website", Prefix = "Welcome to our " });if (result.Text != "Welcome to our website") throw new InvalidOperationException("Prefix result did not match.");if (actions.PrefixText(new TextInput { Text = "website" }).Text != "website") throw new InvalidOperationException("An omitted prefix changed the text.");Console.WriteLine("Both action checks passed.");This invokes the action locally, without contacting Blackbird. It checks the action’s behavior; deploying and flying a Bird checks discovery, platform inputs, and execution.
Invocation context and logging
Section titled “Invocation context and logging”Blackbird supplies InvocationContext to a public BaseInvocable constructor. It contains credentials and available Bird, Flight, organization, URI, and invocation information. In SDK 2.17.0 it also supplies a cancellation token for asynchronous work.
The logger exposes information, warning, error, debug, and critical delegates. It can be absent in local tests, so use null-safe calls as in the example. Log the operation and a safe identifier; keep content, tokens, and authorization headers out of diagnostics. Platform invocation context fields can also be absent in a local test fixture.
Package and validate discovery
Section titled “Package and validate discovery”Follow Deployment to publish and ZIP the App. Add Prefix text to an On demand Bird and fly it with the same input. The Flight should show Welcome to our website in the Text output.
For an integration App, extend local tests to provider errors and credentials with an isolated fixture. CI can compile the library, run those checks, and produce the publish archive before a version is uploaded.