diff --git a/Build/PackageFiles/Dotnet_precompiled/ItemTemplates-Isolated_NetCore_v4.x.nuspec b/Build/PackageFiles/Dotnet_precompiled/ItemTemplates-Isolated_NetCore_v4.x.nuspec index f1ed5b27..ce7bda4c 100644 --- a/Build/PackageFiles/Dotnet_precompiled/ItemTemplates-Isolated_NetCore_v4.x.nuspec +++ b/Build/PackageFiles/Dotnet_precompiled/ItemTemplates-Isolated_NetCore_v4.x.nuspec @@ -41,7 +41,7 @@ - + diff --git a/Build/PackageFiles/Dotnet_precompiled/ItemTemplates-Isolated_NetFx_v4.x.nuspec b/Build/PackageFiles/Dotnet_precompiled/ItemTemplates-Isolated_NetFx_v4.x.nuspec index f2d1586c..9a571956 100644 --- a/Build/PackageFiles/Dotnet_precompiled/ItemTemplates-Isolated_NetFx_v4.x.nuspec +++ b/Build/PackageFiles/Dotnet_precompiled/ItemTemplates-Isolated_NetFx_v4.x.nuspec @@ -41,7 +41,7 @@ - + diff --git a/Build/PackageFiles/Dotnet_precompiled/ItemTemplates-Isolated_v4.x.nuspec b/Build/PackageFiles/Dotnet_precompiled/ItemTemplates-Isolated_v4.x.nuspec index f874c903..36a9d17c 100644 --- a/Build/PackageFiles/Dotnet_precompiled/ItemTemplates-Isolated_v4.x.nuspec +++ b/Build/PackageFiles/Dotnet_precompiled/ItemTemplates-Isolated_v4.x.nuspec @@ -40,7 +40,7 @@ - + diff --git a/Build/PackageFiles/Dotnet_precompiled/ItemTemplates_v4.x.nuspec b/Build/PackageFiles/Dotnet_precompiled/ItemTemplates_v4.x.nuspec index 44a8e19c..15747a44 100644 --- a/Build/PackageFiles/Dotnet_precompiled/ItemTemplates_v4.x.nuspec +++ b/Build/PackageFiles/Dotnet_precompiled/ItemTemplates_v4.x.nuspec @@ -49,9 +49,9 @@ - + \ No newline at end of file diff --git a/Build/PackageFiles/ExtensionBundle/ExtensionBundlePreviewTemplates-4.x.nuspec b/Build/PackageFiles/ExtensionBundle/ExtensionBundlePreviewTemplates-4.x.nuspec index 6f8edbc8..ee4485a2 100644 --- a/Build/PackageFiles/ExtensionBundle/ExtensionBundlePreviewTemplates-4.x.nuspec +++ b/Build/PackageFiles/ExtensionBundle/ExtensionBundlePreviewTemplates-4.x.nuspec @@ -168,6 +168,9 @@ + + + diff --git a/Functions.Templates/Bindings/bindings-bundle-v4.json b/Functions.Templates/Bindings/bindings-bundle-v4.json index 87f9e7f9..9758af6b 100644 --- a/Functions.Templates/Bindings/bindings-bundle-v4.json +++ b/Functions.Templates/Bindings/bindings-bundle-v4.json @@ -2013,6 +2013,269 @@ "help": "[variables('appSettingsHelp')]" } ] + }, + { + "type": "redisPubSubTrigger", + "displayName": "$redisPubSubTrigger_displayName", + "direction": "trigger", + "enabledInTryMode": true, + "documentation": "$content=Documentation\\redisPubSubTrigger.md", + "extension": { + "id": "Microsoft.Azure.WebJobs.Extensions.Redis", "version": "0.5.0-preview" + }, + "settings": [ + { + "name": "name", + "value": "string", + "defaultValue": "changes", + "required": true, + "label": "$redisPubSubTrigger_name_label", + "help": "$redisPubSubTrigger_name_help", + "validators": [ + { + "expression": "^[a-zA-Z][a-zA-Z0-9]{0,127}$", + "errorText": "[variables('parameterName')]" + } + ] + }, + { + "name": "connection", + "value": "string", + "defaultValue": "object", + "required": true, + "label": "$redis_connection_label", + "help": "$redis_connection_help", + "placeholder": "[variables('selectConnection')]" + }, + { + "name": "channel", + "value": "string", + "defaultValue": "object", + "required": true, + "label": "$redisPubSubTrigger_channel_label", + "help": "$redisPubSubTrigger_channel_help" + }, + { + "name": "pattern", + "value": "boolean", + "defaultValue": false, + "required": true, + "label": "$redisPubSubTrigger_pattern_label", + "help": "$redisPubSubTrigger_pattern_help" + } + ] + }, + { + "type": "redisListTrigger", + "displayName": "$redisListTrigger_displayName", + "direction": "trigger", + "enabledInTryMode": true, + "documentation": "$content=Documentation\\redisListTrigger.md", + "extension": { + "id": "Microsoft.Azure.WebJobs.Extensions.Redis", "version": "0.5.0-preview" + }, + "settings": [ + { + "name": "name", + "value": "string", + "defaultValue": "changes", + "required": true, + "label": "$redisListTrigger_name_label", + "help": "$redisListTrigger_name_help", + "validators": [ + { + "expression": "^[a-zA-Z][a-zA-Z0-9]{0,127}$", + "errorText": "[variables('parameterName')]" + } + ] + }, + { + "name": "connection", + "value": "string", + "defaultValue": "object", + "required": true, + "label": "$redis_connection_label", + "help": "$redis_connection_help", + "placeholder": "[variables('selectConnection')]" + }, + { + "name": "key", + "value": "string", + "defaultValue": "object", + "required": true, + "label": "$redisListTrigger_key_label", + "help": "$redisListTrigger_key_help" + }, + { + "name": "pollingIntervalInMs", + "value": "long", + "defaultValue": 1000, + "required": true, + "label": "$redisTrigger_pollingIntervalInMs_label", + "help": "$redisTrigger_pollingIntervalInMs_help" + }, + { + "name": "maxBatchSize", + "value": "int", + "defaultValue": 16, + "required": true, + "label": "$redisTrigger_maxBatchSize_label", + "help": "$redisTrigger_maxBatchSize_help" + }, + { + "name": "listDirection", + "value": "string", + "defaultValue": "LEFT", + "required": true, + "label": "$redisListTrigger_listDirection_label", + "help": "$redisListTrigger_listDirection_help" + } + ] + }, + { + "type": "redisStreamTrigger", + "displayName": "$redisStreamTrigger_displayName", + "direction": "trigger", + "enabledInTryMode": true, + "documentation": "$content=Documentation\\redisStreamTrigger.md", + "extension": { + "id": "Microsoft.Azure.WebJobs.Extensions.Redis", "version": "0.5.0-preview" + }, + "settings": [ + { + "name": "name", + "value": "string", + "defaultValue": "changes", + "required": true, + "label": "$redisStreamTrigger_name_label", + "help": "$redisStreamTrigger_name_help", + "validators": [ + { + "expression": "^[a-zA-Z][a-zA-Z0-9]{0,127}$", + "errorText": "[variables('parameterName')]" + } + ] + }, + { + "name": "connection", + "value": "string", + "defaultValue": "object", + "required": true, + "label": "$redis_connection_label", + "help": "$redis_connection_help", + "placeholder": "[variables('selectConnection')]" + }, + { + "name": "key", + "value": "string", + "defaultValue": "object", + "required": true, + "label": "$redisStreamTrigger_key_label", + "help": "$redisStreamTrigger_key_help" + }, + { + "name": "pollingIntervalInMs", + "value": "long", + "defaultValue": 1000, + "required": true, + "label": "$redisTrigger_pollingIntervalInMs_label", + "help": "$redisTrigger_pollingIntervalInMs_help" + }, + { + "name": "maxBatchSize", + "value": "int", + "defaultValue": 16, + "required": true, + "label": "$redisTrigger_maxBatchSize_label", + "help": "$redisTrigger_maxBatchSize_help" + } + ] + }, + { + "type": "redis", + "displayName": "$redisIn_displayName", + "direction": "in", + "enabledInTryMode": true, + "documentation": "$content=Documentation\\redisIn.md", + "extension": { + "id": "Microsoft.Azure.WebJobs.Extensions.Redis", "version": "0.5.0-preview" + }, + "settings": [ + { + "name": "name", + "value": "string", + "defaultValue": "changes", + "required": true, + "label": "$redisIn_name_label", + "help": "$redisIn_name_help", + "validators": [ + { + "expression": "^[a-zA-Z][a-zA-Z0-9]{0,127}$", + "errorText": "[variables('parameterName')]" + } + ] + }, + { + "name": "connection", + "value": "string", + "defaultValue": "object", + "required": true, + "label": "$redis_connection_label", + "help": "$redis_connection_help", + "placeholder": "[variables('selectConnection')]" + }, + { + "name": "command", + "value": "string", + "defaultValue": "object", + "required": true, + "label": "$redisIn_command_label", + "help": "$redisIn_command_help" + } + ] + }, + { + "type": "redis", + "displayName": "$redisOut_displayName", + "direction": "in", + "enabledInTryMode": true, + "documentation": "$content=Documentation\\redisOut.md", + "extension": { + "id": "Microsoft.Azure.WebJobs.Extensions.Redis", "version": "0.5.0-preview" + }, + "settings": [ + { + "name": "name", + "value": "string", + "defaultValue": "changes", + "required": true, + "label": "$redisOut_name_label", + "help": "$redisOut_name_help", + "validators": [ + { + "expression": "^[a-zA-Z][a-zA-Z0-9]{0,127}$", + "errorText": "[variables('parameterName')]" + } + ] + }, + { + "name": "connection", + "value": "string", + "defaultValue": "object", + "required": true, + "label": "$redis_connection_label", + "help": "$redis_connection_help", + "placeholder": "[variables('selectConnection')]" + }, + { + "name": "command", + "value": "string", + "defaultValue": "object", + "required": true, + "label": "$redisOut_command_label", + "help": "$redisOut_command_help" + } + ] } ] } diff --git a/Functions.Templates/Documentation/redisIn.md b/Functions.Templates/Documentation/redisIn.md new file mode 100644 index 00000000..9644806f --- /dev/null +++ b/Functions.Templates/Documentation/redisIn.md @@ -0,0 +1,26 @@ +#### Settings for Redis Input Binding + +See [Azure Functions Redis Extension](https://github.com/Azure/azure-functions-redis-extension) for general information about all Redis Bindings. + +The settings for a `RedisInput` binding specifies the following properties: + +- `type` : Must be set to *redis*. +- `name` : The name of the parameter that the returned value binds to. +- `direction` : Must be set to *in*. +- `connection` : The name of an app setting that contains the Redis connection information. See the [available connection types](https://github.com/Azure/azure-functions-redis-extension?tab=readme-ov-file#connection-types) for more information. +- `command` : The redis-cli command to be executed on the cache with all arguments separated by spaces. (e.g. `"GET key"`, `"HGET key field"`) + +#### Redis Input Binding C# code example + +This C# code gets any key that was recently set when keyspace notifications are enabled. Please refer to our [samples](https://github.com/Azure/azure-functions-redis-extension/tree/main/samples) for more examples. + +```csharp +[FunctionName(nameof(SetGetter))] +public static void SetGetter( + [RedisPubSubTrigger("Redis", "__keyevent@0__:set")] ChannelMessage message, + [Redis("Redis", "GET {Message}")] string value, + ILogger logger) +{ + logger.LogInformation($"Key '{message.Message}' was set to value '{value}'"); +} +``` diff --git a/Functions.Templates/Documentation/redisOut.md b/Functions.Templates/Documentation/redisOut.md new file mode 100644 index 00000000..c1a278e5 --- /dev/null +++ b/Functions.Templates/Documentation/redisOut.md @@ -0,0 +1,27 @@ +#### Settings for Redis Output Binding + +See [Azure Functions Redis Extension](https://github.com/Azure/azure-functions-redis-extension) for general information about all Redis Bindings. + +The settings for a `RedisOutput` binding specifies the following properties: + +- `type` : Must be set to *redis*. +- `name` : The name of the parameter that the value binds to. +- `direction` : Must be set to *out*. +- `connection` : The name of an app setting that contains the Redis connection information. See the [available connection types](https://github.com/Azure/azure-functions-redis-extension?tab=readme-ov-file#connection-types) for more information. +- `command` : The Redis command to be executed on the cache without any arguments. (e.g. `"GET"`, `"HGET"`) + +#### Redis Output Binding C# code example + +This C# code deletes any key that was recently set when keyspace notifications are enabled. Please refer to our [samples](https://github.com/Azure/azure-functions-redis-extension/tree/main/samples) for more examples. + +```csharp +[FunctionName(nameof(SetDeleter))] +public static void SetDeleter( + [RedisPubSubTrigger("Redis", "__keyevent@0__:set")] ChannelMessage message, + [Redis("Redis", "DEL")] out string arguments, + ILogger logger) +{ + logger.LogInformation($"Deleting recently SET key '{message.Message}'"); + arguments = message.Message; +} +``` diff --git a/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/.template.config/template.json b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/.template.config/template.json new file mode 100644 index 00000000..44b96796 --- /dev/null +++ b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/.template.config/template.json @@ -0,0 +1,71 @@ +{ + "author": "Microsoft", + "classifications": [ + "Azure Function", + "Trigger", + "Redis" + ], + "name": "RedisPubSubTriggerCSharp", + "identity": "Azure.Function.CSharp.Isolated.RedisPubSubTriggerCSharp.3.x", + "groupIdentity": "Azure.Function.RedisPubSubTriggerCSharp", + "shortName": "rqueue", + "tags": { + "language": "C#", + "type": "item" + }, + "sourceName": "RedisPubSubTriggerCSharp", + "symbols": { + "namespace": { + "description": "namespace for the generated code", + "replaces": "Company.Function", + "type": "parameter" + }, + "connection": { + "description": "The name of the app setting containing your Redis connection string.", + "type": "parameter", + "defaultValue": "RedisConnectionString", + "replaces": "RedisConnectionString" + }, + "channel": { + "description": "Redis pubsub channel that the trigger will listen to.", + "type": "parameter", + "defaultValue": "", + "replaces": "redisChannel" + } + }, + "primaryOutputs": [ + { + "path": "RedisPubSubTriggerCSharp.cs" + } + ], + "defaultName": "RedisPubSubTriggerCSharp", + "postActions": [ + { + "Description": "Adding Reference to Microsoft.Azure.Functions.Worker.Extensions.Redis Nuget package", + "ActionId": "B17581D1-C5C9-4489-8F0A-004BE667B814", + "ContinueOnError": "true", + "ManualInstructions": [], + "args": { + "referenceType": "package", + "reference": "Microsoft.Azure.Functions.Worker.Extensions.Redis", "version": "0.5.0-preview", + "projectFileExtensions": ".csproj" + } + }, + { + "description": "Restore NuGet packages required by this project.", + "manualInstructions": [], + "actionId": "210D431B-A78B-4D2F-B762-4ED3E3EA9025", + "continueOnError": true + }, + { + "condition": "(HostIdentifier != \"dotnetcli\" && HostIdentifier != \"dotnetcli-preview\")", + "description": "Opens the function class file in the editor", + "manualInstructions": [], + "actionId": "84C0DA21-51C8-4541-9940-6CA19AF04EE6", + "args": { + "files": "0" + }, + "continueOnError": true + } + ] +} \ No newline at end of file diff --git a/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/.template.config/vs-2017.3.host.json b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/.template.config/vs-2017.3.host.json new file mode 100644 index 00000000..801d2574 --- /dev/null +++ b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/.template.config/vs-2017.3.host.json @@ -0,0 +1,38 @@ +{ + "name": { + "text": "Redis PubSub Trigger", + "package": "{E9BCFE2B-304A-4D7F-836F-F3A4FB1A1451}", + "id": "3000" + }, + "description": { + "text": "A C# function triggers based on messages from a Redis pubsub channel.", + "package": "{E9BCFE2B-304A-4D7F-836F-F3A4FB1A1451}", + "id": "3001" + }, + "order": 1000, + "icon": "vs-2017.3/functionF.png", + "learnMoreLink": "https://github.com/Azure/azure-functions-redis-extension", + "uiFilters": [ + "functions" + ], + "symbolInfo": [ + { + "id": "connection", + "name": { + "id": "4100", + "text": "The name of the app setting containing your Redis connection string", + "package": "{E9BCFE2B-304A-4D7F-836F-F3A4FB1A1451}" + }, + "isVisible": true + }, + { + "id": "channel", + "name": { + "id": "4101", + "text": "Redis pubsub channel that the trigger will listen to.", + "package": "{E9BCFE2B-304A-4D7F-836F-F3A4FB1A1451}" + }, + "isVisible": true + } + ] +} \ No newline at end of file diff --git a/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/.template.config/vs-2017.3/functionF-mac-32.png b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/.template.config/vs-2017.3/functionF-mac-32.png new file mode 100644 index 00000000..962c8309 Binary files /dev/null and b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/.template.config/vs-2017.3/functionF-mac-32.png differ diff --git a/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/.template.config/vs-2017.3/functionF-mac-32@2x.png b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/.template.config/vs-2017.3/functionF-mac-32@2x.png new file mode 100644 index 00000000..efc05321 Binary files /dev/null and b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/.template.config/vs-2017.3/functionF-mac-32@2x.png differ diff --git a/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/.template.config/vs-2017.3/functionF-mac-32~dark.png b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/.template.config/vs-2017.3/functionF-mac-32~dark.png new file mode 100644 index 00000000..dfe1af85 Binary files /dev/null and b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/.template.config/vs-2017.3/functionF-mac-32~dark.png differ diff --git a/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/.template.config/vs-2017.3/functionF-mac-32~dark@2x.png b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/.template.config/vs-2017.3/functionF-mac-32~dark@2x.png new file mode 100644 index 00000000..c267fd04 Binary files /dev/null and b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/.template.config/vs-2017.3/functionF-mac-32~dark@2x.png differ diff --git a/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/.template.config/vs-2017.3/functionF-mac-32~dark~sel.png b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/.template.config/vs-2017.3/functionF-mac-32~dark~sel.png new file mode 100644 index 00000000..3de3643a Binary files /dev/null and b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/.template.config/vs-2017.3/functionF-mac-32~dark~sel.png differ diff --git a/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/.template.config/vs-2017.3/functionF-mac-32~dark~sel@2x.png b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/.template.config/vs-2017.3/functionF-mac-32~dark~sel@2x.png new file mode 100644 index 00000000..57dd6d2c Binary files /dev/null and b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/.template.config/vs-2017.3/functionF-mac-32~dark~sel@2x.png differ diff --git a/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/.template.config/vs-2017.3/functionF-mac-32~sel.png b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/.template.config/vs-2017.3/functionF-mac-32~sel.png new file mode 100644 index 00000000..3de3643a Binary files /dev/null and b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/.template.config/vs-2017.3/functionF-mac-32~sel.png differ diff --git a/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/.template.config/vs-2017.3/functionF-mac-32~sel@2x.png b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/.template.config/vs-2017.3/functionF-mac-32~sel@2x.png new file mode 100644 index 00000000..57dd6d2c Binary files /dev/null and b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/.template.config/vs-2017.3/functionF-mac-32~sel@2x.png differ diff --git a/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/.template.config/vs-2017.3/functionF.png b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/.template.config/vs-2017.3/functionF.png new file mode 100644 index 00000000..6f659f3c Binary files /dev/null and b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/.template.config/vs-2017.3/functionF.png differ diff --git a/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/RedisPubSubTriggerCSharp.cs b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/RedisPubSubTriggerCSharp.cs new file mode 100644 index 00000000..52f3d666 --- /dev/null +++ b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp-Isolated/RedisPubSubTriggerCSharp.cs @@ -0,0 +1,30 @@ +using Microsoft.Azure.Functions.Worker.Extensions.Redis; +using Microsoft.Extensions.Logging; + +namespace Company.Function +{ + public class RedisPubSubTriggerCSharp + { + private readonly ILogger logger; + + public RedisPubSubTriggerCSharp(ILogger logger) + { + this.logger = logger; + } + + [Function(nameof(RedisPubSubTriggerCSharp))] + public static void Run( + [RedisPubSubTrigger("RedisConnectionString", "redisChannel")] ChannelMessage message, + ILogger log) + { + log.LogInformation($"Message '{message.Message}' was pushed to channel '{message.Channel}'"); + } + } + + public class ChannelMessage + { + public string SubscriptionChannel { get; set; } + public string Channel { get; set; } + public string Message { get; set; } + } +} diff --git a/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/.template.config/template.json b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/.template.config/template.json new file mode 100644 index 00000000..15c3795f --- /dev/null +++ b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/.template.config/template.json @@ -0,0 +1,71 @@ +{ + "author": "Microsoft", + "classifications": [ + "Azure Function", + "Trigger", + "Redis" + ], + "name": "RedisPubSubTrigger", + "identity": "Azure.Function.CSharp.RedisPubSubTrigger", + "groupIdentity": "Azure.Function.RedisPubSubTrigger", + "shortName": "redisPubSubTrigger", + "tags": { + "language": "C#", + "type": "item" + }, + "sourceName": "RedisPubSubTriggerCSharp", + "symbols": { + "namespace": { + "description": "namespace for the generated code", + "replaces": "Company.Function", + "type": "parameter" + }, + "connection": { + "description": "The name of the app setting containing your Redis connection string.", + "type": "parameter", + "defaultValue": "RedisConnectionString", + "replaces": "RedisConnectionString" + }, + "channel": { + "description": "Redis pubsub channel that the trigger will listen to.", + "type": "parameter", + "defaultValue": "", + "replaces": "redisChannel" + } + }, + "primaryOutputs": [ + { + "path": "RedisPubSubTriggerCSharp.cs" + } + ], + "defaultName": "RedisPubSubTriggerCSharp", + "postActions": [ + { + "Description": "Adding Reference to Microsoft.Azure.WebJobs.Extensions.Redis Nuget package", + "ActionId": "B17581D1-C5C9-4489-8F0A-004BE667B814", + "ContinueOnError": "true", + "ManualInstructions": [], + "args": { + "referenceType": "package", + "reference": "Microsoft.Azure.WebJobs.Extensions.Redis", "version": "0.5.0-preview", + "projectFileExtensions": ".csproj" + } + }, + { + "description": "Restore NuGet packages required by this project.", + "manualInstructions": [], + "actionId": "210D431B-A78B-4D2F-B762-4ED3E3EA9025", + "continueOnError": true + }, + { + "condition": "(HostIdentifier != \"dotnetcli\" && HostIdentifier != \"dotnetcli-preview\")", + "description": "Opens the function class file in the editor", + "manualInstructions": [], + "actionId": "84C0DA21-51C8-4541-9940-6CA19AF04EE6", + "args": { + "files": "0" + }, + "continueOnError": true + } + ] +} diff --git a/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/.template.config/vs-2017.3.host.json b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/.template.config/vs-2017.3.host.json new file mode 100644 index 00000000..b73afefa --- /dev/null +++ b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/.template.config/vs-2017.3.host.json @@ -0,0 +1,38 @@ +{ + "name": { + "text": "Redis PubSub Trigger", + "package": "{E9BCFE2B-304A-4D7F-836F-F3A4FB1A1451}", + "id": "3000" + }, + "description": { + "text": "A C# function triggers based on messages from a Redis pubsub channel.", + "package": "{E9BCFE2B-304A-4D7F-836F-F3A4FB1A1451}", + "id": "3001" + }, + "order": 400, + "icon": "vs-2017.3/functionF.png", + "learnMoreLink": "https://github.com/Azure/azure-functions-redis-extension", + "uiFilters": [ + "functions" + ], + "symbolInfo": [ + { + "id": "connection", + "name": { + "id": "4100", + "text": "The name of the app setting containing your Redis connection string", + "package": "{E9BCFE2B-304A-4D7F-836F-F3A4FB1A1451}" + }, + "isVisible": true + }, + { + "id": "channel", + "name": { + "id": "4101", + "text": "Redis pubsub channel that the trigger will listen to.", + "package": "{E9BCFE2B-304A-4D7F-836F-F3A4FB1A1451}" + }, + "isVisible": true + } + ] +} \ No newline at end of file diff --git a/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/.template.config/vs-2017.3/functionF-mac-32.png b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/.template.config/vs-2017.3/functionF-mac-32.png new file mode 100644 index 00000000..962c8309 Binary files /dev/null and b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/.template.config/vs-2017.3/functionF-mac-32.png differ diff --git a/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/.template.config/vs-2017.3/functionF-mac-32@2x.png b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/.template.config/vs-2017.3/functionF-mac-32@2x.png new file mode 100644 index 00000000..efc05321 Binary files /dev/null and b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/.template.config/vs-2017.3/functionF-mac-32@2x.png differ diff --git a/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/.template.config/vs-2017.3/functionF-mac-32~dark.png b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/.template.config/vs-2017.3/functionF-mac-32~dark.png new file mode 100644 index 00000000..dfe1af85 Binary files /dev/null and b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/.template.config/vs-2017.3/functionF-mac-32~dark.png differ diff --git a/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/.template.config/vs-2017.3/functionF-mac-32~dark@2x.png b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/.template.config/vs-2017.3/functionF-mac-32~dark@2x.png new file mode 100644 index 00000000..c267fd04 Binary files /dev/null and b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/.template.config/vs-2017.3/functionF-mac-32~dark@2x.png differ diff --git a/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/.template.config/vs-2017.3/functionF-mac-32~dark~sel.png b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/.template.config/vs-2017.3/functionF-mac-32~dark~sel.png new file mode 100644 index 00000000..3de3643a Binary files /dev/null and b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/.template.config/vs-2017.3/functionF-mac-32~dark~sel.png differ diff --git a/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/.template.config/vs-2017.3/functionF-mac-32~dark~sel@2x.png b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/.template.config/vs-2017.3/functionF-mac-32~dark~sel@2x.png new file mode 100644 index 00000000..57dd6d2c Binary files /dev/null and b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/.template.config/vs-2017.3/functionF-mac-32~dark~sel@2x.png differ diff --git a/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/.template.config/vs-2017.3/functionF-mac-32~sel.png b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/.template.config/vs-2017.3/functionF-mac-32~sel.png new file mode 100644 index 00000000..3de3643a Binary files /dev/null and b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/.template.config/vs-2017.3/functionF-mac-32~sel.png differ diff --git a/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/.template.config/vs-2017.3/functionF-mac-32~sel@2x.png b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/.template.config/vs-2017.3/functionF-mac-32~sel@2x.png new file mode 100644 index 00000000..57dd6d2c Binary files /dev/null and b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/.template.config/vs-2017.3/functionF-mac-32~sel@2x.png differ diff --git a/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/.template.config/vs-2017.3/functionF.png b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/.template.config/vs-2017.3/functionF.png new file mode 100644 index 00000000..6f659f3c Binary files /dev/null and b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/.template.config/vs-2017.3/functionF.png differ diff --git a/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/RedisPubSubTriggerCSharp.cs b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/RedisPubSubTriggerCSharp.cs new file mode 100644 index 00000000..62e5e864 --- /dev/null +++ b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/RedisPubSubTriggerCSharp.cs @@ -0,0 +1,24 @@ +using Microsoft.Azure.WebJobs; +using Microsoft.Azure.WebJobs.Extensions.Redis; +using Microsoft.Extensions.Logging; + +namespace Company.Function +{ + public static class RedisPubSubTriggerCSharp + { + [FunctionName(nameof(RedisPubSubTriggerCSharp))] + public static void Run( + [RedisPubSubTrigger("RedisConnectionString", "redisChannel")] ChannelMessage message, + ILogger log) + { + log.LogInformation($"Message '{message.Message}' was pushed to channel '{message.Channel}'"); + } + } + + public class ChannelMessage + { + public string SubscriptionChannel { get; set; } + public string Channel { get; set; } + public string Message { get; set; } + } +} diff --git a/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/function.json b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/function.json new file mode 100644 index 00000000..8e44bed0 --- /dev/null +++ b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/function.json @@ -0,0 +1,13 @@ +{ + "bindings": [ + { + "type": "redisPubSubTrigger", + "name": "message", + "direction": "in", + "connection": "RedisConnectionString", + "channel": "channelname", + "pattern": false + } + ], + "disabled": false +} \ No newline at end of file diff --git a/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/metadata.json b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/metadata.json new file mode 100644 index 00000000..d6e133fa --- /dev/null +++ b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/metadata.json @@ -0,0 +1,15 @@ +{ + "defaultFunctionName": "RedisPubSubTrigger", + "description": "$RedisPubSubTrigger_description", + "name": "Redis PubSub Trigger", + "language": "C#", + "category": [ + "$temp_category_core", + "$temp_category_dataProcessing" + ], + "categoryStyle": "other", + "enabledInTryMode": false, + "userPrompt": [ + "channel" + ] +} diff --git a/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/readme.md b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/readme.md new file mode 100644 index 00000000..9e3e595d --- /dev/null +++ b/Functions.Templates/Templates/RedisPubSubTrigger-CSharp/readme.md @@ -0,0 +1,22 @@ +# Redis PubSub Trigger Binding - C# + +The `Redis PubSub Trigger Binding` invokes the function on messages published to a channel. + +## How it works + +For a `RedisPubSubTrigger` to work, you must provide a Redis channel name that defines the pubsub channel that messages will be read from. +Add a `RedisConnectionString` field to your `local.settings.json` with the connection string: +```json +{ + "IsEncrypted": false, + "Values": { + "AzureWebJobsStorage": "UseDevelopmentStorage=true", + "FUNCTIONS_WORKER_RUNTIME": "dotnet", + "RedisConnectionString": ".redis.cache.windows.net:6380,password=" + } +} +``` + +## Learn more + +For more information, visit the [azure-functions-redis-extension repository](https://github.com/Azure/azure-functions-redis-extension). \ No newline at end of file