diff --git a/Kudu.Core/Functions/KedaFunctionTriggerProvider.cs b/Kudu.Core/Functions/KedaFunctionTriggerProvider.cs index d1a932fb..c4934a2e 100644 --- a/Kudu.Core/Functions/KedaFunctionTriggerProvider.cs +++ b/Kudu.Core/Functions/KedaFunctionTriggerProvider.cs @@ -48,7 +48,7 @@ bool IsFunctionJson(string fullName) return fullName.EndsWith(Constants.FunctionsConfigFile) && fullName.Count(c => c == '/' || c == '\\') == 1; } - + return kedaScaleTriggers; } @@ -85,7 +85,7 @@ public IEnumerable ParseFunctionJson(string functionName, string f { var scaleTrigger = new ScaleTrigger { - Type = type, + Type = GetKedaTriggerType(type), Metadata = new Dictionary() }; foreach (var property in binding) @@ -113,5 +113,39 @@ private static string GetFunctionName(ZipArchiveEntry zipEnetry) return zipEnetry.FullName.Split('/').Length == 2 ? zipEnetry.FullName.Split('/')[0] : zipEnetry.FullName.Split('\\')[0]; } + + private static string GetKedaTriggerType(string triggerType) + { + if (string.IsNullOrEmpty(triggerType)) + { + throw new ArgumentNullException(nameof(triggerType)); + } + + triggerType = triggerType.ToLower(); + + switch (triggerType) + { + case "queuetrigger": + return "azure-queue"; + + case "kafkatrigger": + return "kafka"; + + case "blobtrigger": + return "azure-blob"; + + case "servicebustrigger": + return "azure-servicebus"; + + case "eventhubtrigger": + return "azure-eventhub"; + + case "rabbitmqtrigger": + return "rabbitmq"; + + default: + return triggerType; + } + } } } diff --git a/Kudu.Core/Infrastructure/DockerContainerRestartTrigger.cs b/Kudu.Core/Infrastructure/DockerContainerRestartTrigger.cs index f5020170..1e40d2ae 100644 --- a/Kudu.Core/Infrastructure/DockerContainerRestartTrigger.cs +++ b/Kudu.Core/Infrastructure/DockerContainerRestartTrigger.cs @@ -36,7 +36,7 @@ public static void RequestContainerRestart(IEnvironment environment, string reas //Only for function apps functionTriggers will be non-null/non-empty if (functionTriggers?.Any() == true) { - K8SEDeploymentHelper.UpdateFunctionApp(appName, functionTriggers, buildNumber); + K8SEDeploymentHelper.UpdateFunctionAppTriggers(appName, functionTriggers, $"{buildNumber}|{appName}"); } else { diff --git a/Kudu.Core/K8SE/BuildCtlArgumentsHelper.cs b/Kudu.Core/K8SE/BuildCtlArgumentsHelper.cs index a08d3766..384e6974 100644 --- a/Kudu.Core/K8SE/BuildCtlArgumentsHelper.cs +++ b/Kudu.Core/K8SE/BuildCtlArgumentsHelper.cs @@ -26,7 +26,7 @@ internal static void AddAppPropertyValueArgument(StringBuilder args, string appP args.AppendFormat(" -appPropertyValue {0}", appPropertyValue); } - internal static void AddJsonToPatchValueArgument(StringBuilder args, string jsonToPatch) + internal static void AddFunctionTriggersJsonToPatchValueArgument(StringBuilder args, string jsonToPatch) { args.AppendFormat(" -jsonToPatch {0}", jsonToPatch); } diff --git a/Kudu.Core/K8SE/K8SEDeploymentHelper.cs b/Kudu.Core/K8SE/K8SEDeploymentHelper.cs index 89cfbc60..6954c6f3 100644 --- a/Kudu.Core/K8SE/K8SEDeploymentHelper.cs +++ b/Kudu.Core/K8SE/K8SEDeploymentHelper.cs @@ -71,19 +71,20 @@ public static void UpdateFunctionAppTriggers(string appName, IEnumerable function } }; - return JsonConvert.SerializeObject(patchAppJson, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); + var patchJson = JsonConvert.SerializeObject(patchAppJson, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); + var patchJsonString = JsonConvert.ToString(patchJson); + return patchJsonString; } } }