From bce536c90892599000ca807c1f90b313ea6bbea3 Mon Sep 17 00:00:00 2001 From: MaddyDev Date: Tue, 18 Jun 2024 11:42:17 -0700 Subject: [PATCH 01/16] add integrayion test and use just functionName in userFunctionId --- src/TriggerBinding/SqlTriggerBinding.cs | 2 +- .../SqlTriggerBindingIntegrationTests.cs | 63 +++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/src/TriggerBinding/SqlTriggerBinding.cs b/src/TriggerBinding/SqlTriggerBinding.cs index 323e8fa3d..eb1432a40 100644 --- a/src/TriggerBinding/SqlTriggerBinding.cs +++ b/src/TriggerBinding/SqlTriggerBinding.cs @@ -107,7 +107,7 @@ private string GetUserFunctionId() string websiteName = SqlBindingUtilities.GetWebSiteName(this._configuration); var methodInfo = (MethodInfo)this._parameter.Member; - string functionName = $"{methodInfo.DeclaringType.FullName}.{methodInfo.Name}"; + string functionName = $"{methodInfo.DeclaringType.Name}"; using (var sha256 = SHA256.Create()) { diff --git a/test/Integration/SqlTriggerBindingIntegrationTests.cs b/test/Integration/SqlTriggerBindingIntegrationTests.cs index 02dd601de..624514e97 100644 --- a/test/Integration/SqlTriggerBindingIntegrationTests.cs +++ b/test/Integration/SqlTriggerBindingIntegrationTests.cs @@ -872,5 +872,68 @@ public async Task NewUserFunctionId_Migration_Test() Assert.True(1 == (int)this.ExecuteScalar($@"SELECT 1 FROM {GlobalStateTableName} WHERE UserFunctionID = N'{userFunctionId}'"), $"{GlobalStateTableName} should have {userFunctionId} row on successful migration"); Assert.True(lastSyncVersion == (long)this.ExecuteScalar($@"SELECT LastSyncVersion FROM {GlobalStateTableName} WHERE UserFunctionID = N'{userFunctionId}'"), $"{GlobalStateTableName} should have {userFunctionId} row woth on successful migration"); } + + /// + /// Ensures that the user function gets invoked for each of the insert, update and delete operation after migration seamlessly. + /// + [RetryTheory] + [SqlInlineData()] + [UnsupportedLanguages(SupportedLanguages.Java)] // test timing out for Java + public async Task UserFunctionIdMigrationTriggerTest(SupportedLanguages lang) + { + this.SetChangeTrackingForTable("Products"); + string userFunctionId = "func-id"; + string newUserFuntionId = "new-func-id"; + IConfiguration configuration = new ConfigurationBuilder().Build(); + var listener = new SqlTriggerListener(this.DbConnectionString, "dbo.Products", "", userFunctionId, "", Mock.Of(), Mock.Of(), Mock.Of(), configuration); + await listener.StartAsync(CancellationToken.None); + // Cancel immediately so the listener doesn't start processing the changes + await listener.StopAsync(CancellationToken.None); + + this.StartFunctionHost(nameof(ProductsTrigger), lang); + + int firstId = 1; + int lastId = 30; + await this.WaitForProductChanges( + firstId, + lastId, + SqlChangeOperation.Insert, + () => { this.InsertProducts(firstId, lastId); return Task.CompletedTask; }, + id => $"Product {id}", + id => id * 100, + this.GetBatchProcessingTimeout(firstId, lastId)); + + listener = new SqlTriggerListener(this.DbConnectionString, "dbo.Products", "", newUserFuntionId, userFunctionId, Mock.Of(), Mock.Of(), Mock.Of(), configuration); + await listener.StartAsync(CancellationToken.None); + // Cancel immediately so the listener doesn't start processing the changes + await listener.StopAsync(CancellationToken.None); + + this.StartFunctionHost(nameof(ProductsTrigger), lang); + + firstId = 1; + lastId = 20; + // All table columns (not just the columns that were updated) would be returned for update operation. + await this.WaitForProductChanges( + firstId, + lastId, + SqlChangeOperation.Update, + () => { this.UpdateProducts(firstId, lastId); return Task.CompletedTask; }, + id => $"Updated Product {id}", + id => id * 100, + this.GetBatchProcessingTimeout(firstId, lastId)); + + firstId = 11; + lastId = 30; + // The properties corresponding to non-primary key columns would be set to the C# type's default values + // (null and 0) for delete operation. + await this.WaitForProductChanges( + firstId, + lastId, + SqlChangeOperation.Delete, + () => { this.DeleteProducts(firstId, lastId); return Task.CompletedTask; }, + _ => null, + _ => 0, + this.GetBatchProcessingTimeout(firstId, lastId)); + } } } \ No newline at end of file From b5aa8293112d8164037a4c702c167b52f758daf2 Mon Sep 17 00:00:00 2001 From: MaddyDev Date: Wed, 19 Jun 2024 11:58:37 -0700 Subject: [PATCH 02/16] make websitename required --- samples/samples-csharp/local.settings.json | 1 + samples/samples-csx/local.settings.json | 1 + samples/samples-java/local.settings.json | 1 + samples/samples-js-v4/local.settings.json | 3 ++- samples/samples-js/local.settings.json | 1 + samples/samples-outofproc/local.settings.json | 1 + samples/samples-powershell/local.settings.json | 1 + samples/samples-python-v2/local.settings.json | 1 + samples/samples-python/local.settings.json | 1 + src/SqlBindingUtilities.cs | 9 ++++++++- 10 files changed, 18 insertions(+), 2 deletions(-) diff --git a/samples/samples-csharp/local.settings.json b/samples/samples-csharp/local.settings.json index 2ee8fdfec..11a573a93 100644 --- a/samples/samples-csharp/local.settings.json +++ b/samples/samples-csharp/local.settings.json @@ -4,6 +4,7 @@ "AzureWebJobsStorage": "UseDevelopmentStorage=true", "FUNCTIONS_WORKER_RUNTIME": "dotnet", "SqlConnectionString": "", + "WEBSITE_SITE_NAME": "SamplesCSharp", "Sp_SelectCost": "SelectProductsCost", "ProductCost": 100 } diff --git a/samples/samples-csx/local.settings.json b/samples/samples-csx/local.settings.json index 2ee8fdfec..2780f8f8d 100644 --- a/samples/samples-csx/local.settings.json +++ b/samples/samples-csx/local.settings.json @@ -4,6 +4,7 @@ "AzureWebJobsStorage": "UseDevelopmentStorage=true", "FUNCTIONS_WORKER_RUNTIME": "dotnet", "SqlConnectionString": "", + "WEBSITE_SITE_NAME": "SamplesCsx", "Sp_SelectCost": "SelectProductsCost", "ProductCost": 100 } diff --git a/samples/samples-java/local.settings.json b/samples/samples-java/local.settings.json index 520adf666..49701c41c 100644 --- a/samples/samples-java/local.settings.json +++ b/samples/samples-java/local.settings.json @@ -4,6 +4,7 @@ "AzureWebJobsStorage": "UseDevelopmentStorage=true", "FUNCTIONS_WORKER_RUNTIME": "java", "SqlConnectionString": "", + "WEBSITE_SITE_NAME": "SamplesJava", "Sp_SelectCost": "SelectProductsCost", "ProductCost": 100 } diff --git a/samples/samples-js-v4/local.settings.json b/samples/samples-js-v4/local.settings.json index 2609bea7d..9765f08a6 100644 --- a/samples/samples-js-v4/local.settings.json +++ b/samples/samples-js-v4/local.settings.json @@ -4,6 +4,7 @@ "AzureWebJobsStorage": "UseDevelopmentStorage=true", "FUNCTIONS_WORKER_RUNTIME": "node", "AzureWebJobsFeatureFlags": "EnableWorkerIndexing", - "SqlConnectionString": "" + "SqlConnectionString": "", + "WEBSITE_SITE_NAME": "SamplesNodeV4" } } \ No newline at end of file diff --git a/samples/samples-js/local.settings.json b/samples/samples-js/local.settings.json index d420cc65e..419f9a0fc 100644 --- a/samples/samples-js/local.settings.json +++ b/samples/samples-js/local.settings.json @@ -4,6 +4,7 @@ "AzureWebJobsStorage": "UseDevelopmentStorage=true", "FUNCTIONS_WORKER_RUNTIME": "node", "SqlConnectionString": "", + "WEBSITE_SITE_NAME": "SamplesJavascript", "Sp_SelectCost": "SelectProductsCost", "ProductCost": 100 } diff --git a/samples/samples-outofproc/local.settings.json b/samples/samples-outofproc/local.settings.json index fda4854dd..b941acc76 100644 --- a/samples/samples-outofproc/local.settings.json +++ b/samples/samples-outofproc/local.settings.json @@ -4,6 +4,7 @@ "AzureWebJobsStorage": "UseDevelopmentStorage=true", "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated", "SqlConnectionString": "", + "WEBSITE_SITE_NAME": "SamplesOOP", "Sp_SelectCost": "SelectProductsCost", "ProductCost": 100 } diff --git a/samples/samples-powershell/local.settings.json b/samples/samples-powershell/local.settings.json index aac210146..6e4d9ba9b 100644 --- a/samples/samples-powershell/local.settings.json +++ b/samples/samples-powershell/local.settings.json @@ -5,6 +5,7 @@ "FUNCTIONS_WORKER_RUNTIME": "powershell", "FUNCTIONS_WORKER_RUNTIME_VERSION" : "~7.2", "SqlConnectionString": "", + "WEBSITE_SITE_NAME": "SamplesPowershell", "Sp_SelectCost": "SelectProductsCost", "ProductCost": 100 } diff --git a/samples/samples-python-v2/local.settings.json b/samples/samples-python-v2/local.settings.json index 9f6f238ce..881aeeed5 100644 --- a/samples/samples-python-v2/local.settings.json +++ b/samples/samples-python-v2/local.settings.json @@ -5,6 +5,7 @@ "AzureWebJobsStorage": "UseDevelopmentStorage=true", "AzureWebJobsFeatureFlags": "EnableWorkerIndexing", "SqlConnectionString": "", + "WEBSITE_SITE_NAME": "SamplesPythonV2", "PYTHON_ISOLATE_WORKER_DEPENDENCIES": "1" } } \ No newline at end of file diff --git a/samples/samples-python/local.settings.json b/samples/samples-python/local.settings.json index 687701584..38d7dff61 100644 --- a/samples/samples-python/local.settings.json +++ b/samples/samples-python/local.settings.json @@ -4,6 +4,7 @@ "AzureWebJobsStorage": "UseDevelopmentStorage=true", "FUNCTIONS_WORKER_RUNTIME": "python", "SqlConnectionString": "", + "WEBSITE_SITE_NAME": "SamplesPython", "Sp_SelectCost": "SelectProductsCost", "ProductCost": 100 } diff --git a/src/SqlBindingUtilities.cs b/src/SqlBindingUtilities.cs index 59fec983e..f54018cdf 100644 --- a/src/SqlBindingUtilities.cs +++ b/src/SqlBindingUtilities.cs @@ -60,7 +60,14 @@ public static string GetWebSiteName(IConfiguration configuration) { throw new ArgumentNullException(nameof(configuration)); } - return configuration.GetConnectionStringOrSetting(SqlBindingConstants.WEBSITENAME); + string websitename = configuration.GetConnectionStringOrSetting(SqlBindingConstants.WEBSITENAME); + // We require a WEBSITE_SITE_NAME for avoiding duplicates if users use the same function name accross apps. + if (string.IsNullOrEmpty(websitename)) + { + throw new ArgumentException(websitename == null ? $"WEBSITE_SITE_NAME setting is missing in your function app settings, please add the setting with a string value." : + $"WEBSITE_SITE_NAME setting is empty in your function app settings, please update the setting with a string value."); + } + return websitename; } /// From 84ab0db48e5fe343f1548ef3f7422e5a069ea644 Mon Sep 17 00:00:00 2001 From: MaddyDev Date: Thu, 20 Jun 2024 21:03:00 -0700 Subject: [PATCH 03/16] add docs --- docs/BindingsOverview.md | 6 ++++++ src/SqlBindingUtilities.cs | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/BindingsOverview.md b/docs/BindingsOverview.md index bd6c477b6..08a77c9a7 100644 --- a/docs/BindingsOverview.md +++ b/docs/BindingsOverview.md @@ -152,6 +152,12 @@ The delay in milliseconds between processing each batch of changes. The upper limit on the number of pending changes in the user table that are allowed per application-worker. If the count of changes exceeds this limit, it may result in a scale out. The setting only applies for Azure Function Apps with runtime driven scaling enabled. See the [Scaling](#scaling-for-trigger-bindings) section for more information. +#### WEBSITE_SITE_NAME + +The unique name used in creating the lease tables. The local apps depend on this setting for creating unique leases tables, please give a unique name for each app. + > **NOTE:** If the setting is re-used accross apps, having the same function name could cause the functions to use the same lease tables and the function runs to not work as expected. + > **NOTE:** This is a read-only variable that is provided by the azure environment variables for deployed functions and the user provided value will be overridden. Refer to [Environment variables](https://learn.microsoft.com/azure/app-service/reference-app-settings?tabs=kudu%2Cdotnet#app-environment) for apps. + ### Scaling for Trigger Bindings If your application containing functions with SQL trigger bindings is running as an Azure function app, it will be scaled automatically based on the amount of changes that are pending to be processed in the user table. As of today, we only support scaling of function apps running in Elastic Premium plan with 'Runtime Scale Monitoring' enabled. To enable scaling, you will need to go the function app resource's page on Azure Portal, then to Configuration > 'Function runtime settings' and turn on 'Runtime Scale Monitoring'. diff --git a/src/SqlBindingUtilities.cs b/src/SqlBindingUtilities.cs index f54018cdf..818cb8f37 100644 --- a/src/SqlBindingUtilities.cs +++ b/src/SqlBindingUtilities.cs @@ -64,7 +64,7 @@ public static string GetWebSiteName(IConfiguration configuration) // We require a WEBSITE_SITE_NAME for avoiding duplicates if users use the same function name accross apps. if (string.IsNullOrEmpty(websitename)) { - throw new ArgumentException(websitename == null ? $"WEBSITE_SITE_NAME setting is missing in your function app settings, please add the setting with a string value." : + throw new ArgumentException(websitename == null ? $"WEBSITE_SITE_NAME setting is missing in your function app settings, please add the setting with a string value. Please refer to https://github.com/Azure/azure-functions-sql-extension/blob/main/docs/BindingsOverview.md#website_site_name for more information." : $"WEBSITE_SITE_NAME setting is empty in your function app settings, please update the setting with a string value."); } return websitename; From c663857f5dc5c0aa43ae0da8d41b76ecbfec0fa4 Mon Sep 17 00:00:00 2001 From: MaddyDev Date: Thu, 20 Jun 2024 21:03:38 -0700 Subject: [PATCH 04/16] use MethodInfo.Name --- src/TriggerBinding/SqlTriggerBinding.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TriggerBinding/SqlTriggerBinding.cs b/src/TriggerBinding/SqlTriggerBinding.cs index eb1432a40..9aeb2b2c7 100644 --- a/src/TriggerBinding/SqlTriggerBinding.cs +++ b/src/TriggerBinding/SqlTriggerBinding.cs @@ -107,7 +107,7 @@ private string GetUserFunctionId() string websiteName = SqlBindingUtilities.GetWebSiteName(this._configuration); var methodInfo = (MethodInfo)this._parameter.Member; - string functionName = $"{methodInfo.DeclaringType.Name}"; + string functionName = $"{methodInfo.Name}"; using (var sha256 = SHA256.Create()) { From b9921a4d763470cd71a209d357e504b081eabc5d Mon Sep 17 00:00:00 2001 From: MaddyDev Date: Mon, 24 Jun 2024 12:07:34 -0700 Subject: [PATCH 05/16] update error msg --- src/SqlBindingUtilities.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/SqlBindingUtilities.cs b/src/SqlBindingUtilities.cs index 818cb8f37..0a7553bf6 100644 --- a/src/SqlBindingUtilities.cs +++ b/src/SqlBindingUtilities.cs @@ -64,8 +64,7 @@ public static string GetWebSiteName(IConfiguration configuration) // We require a WEBSITE_SITE_NAME for avoiding duplicates if users use the same function name accross apps. if (string.IsNullOrEmpty(websitename)) { - throw new ArgumentException(websitename == null ? $"WEBSITE_SITE_NAME setting is missing in your function app settings, please add the setting with a string value. Please refer to https://github.com/Azure/azure-functions-sql-extension/blob/main/docs/BindingsOverview.md#website_site_name for more information." : - $"WEBSITE_SITE_NAME setting is empty in your function app settings, please update the setting with a string value."); + throw new ArgumentException($"WEBSITE_SITE_NAME cannot be null or empty in your function app settings, please update the setting with a string value. Please refer to https://github.com/Azure/azure-functions-sql-extension/blob/main/docs/BindingsOverview.md#website_site_name for more information."); } return websitename; } From 51c21538ed5e1f03f6d02ac3bd6b6b2b0b547f79 Mon Sep 17 00:00:00 2001 From: MaddyDev Date: Tue, 25 Jun 2024 13:21:22 -0700 Subject: [PATCH 06/16] methodInfo.DeclaringType.Name --- src/TriggerBinding/SqlTriggerBinding.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TriggerBinding/SqlTriggerBinding.cs b/src/TriggerBinding/SqlTriggerBinding.cs index 9aeb2b2c7..eb1432a40 100644 --- a/src/TriggerBinding/SqlTriggerBinding.cs +++ b/src/TriggerBinding/SqlTriggerBinding.cs @@ -107,7 +107,7 @@ private string GetUserFunctionId() string websiteName = SqlBindingUtilities.GetWebSiteName(this._configuration); var methodInfo = (MethodInfo)this._parameter.Member; - string functionName = $"{methodInfo.Name}"; + string functionName = $"{methodInfo.DeclaringType.Name}"; using (var sha256 = SHA256.Create()) { From ffc0a910484c588c5afa3584676b0b1235fd3bb3 Mon Sep 17 00:00:00 2001 From: MaddyDev Date: Wed, 3 Jul 2024 13:42:40 -0700 Subject: [PATCH 07/16] update doc --- docs/BindingsOverview.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/BindingsOverview.md b/docs/BindingsOverview.md index 08a77c9a7..c3631956e 100644 --- a/docs/BindingsOverview.md +++ b/docs/BindingsOverview.md @@ -156,6 +156,7 @@ The upper limit on the number of pending changes in the user table that are allo The unique name used in creating the lease tables. The local apps depend on this setting for creating unique leases tables, please give a unique name for each app. > **NOTE:** If the setting is re-used accross apps, having the same function name could cause the functions to use the same lease tables and the function runs to not work as expected. + > **NOTE:** If you have 2 different SQL trigger functions with same functionName locally, not having WEBSITE_SITE_NAME would mean that the same leasees table would be used for both triggers resulting in only one of the functions being triggered. > **NOTE:** This is a read-only variable that is provided by the azure environment variables for deployed functions and the user provided value will be overridden. Refer to [Environment variables](https://learn.microsoft.com/azure/app-service/reference-app-settings?tabs=kudu%2Cdotnet#app-environment) for apps. ### Scaling for Trigger Bindings From b587e5ebd8b8eb82ed91898fe760ef349e0768c5 Mon Sep 17 00:00:00 2001 From: MaddyDev Date: Mon, 8 Jul 2024 15:21:26 -0700 Subject: [PATCH 08/16] set WEBSITE_SITE_NAME for tests --- test/Common/TestUtils.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/Common/TestUtils.cs b/test/Common/TestUtils.cs index 43f045f86..04c3b15f8 100644 --- a/test/Common/TestUtils.cs +++ b/test/Common/TestUtils.cs @@ -122,8 +122,9 @@ public static void SetupDatabase(out string MasterConnectionString, out string D connectionStringBuilder.InitialCatalog = databaseName; - // Set SqlConnectionString env var for the tests to use + // Set SqlConnectionString and WEBSITE_SITE_NAME env variables for the tests to use Environment.SetEnvironmentVariable("SqlConnectionString", connectionStringBuilder.ToString()); + Environment.SetEnvironmentVariable("WEBSITE_SITE_NAME", "TestSqlFunction"); MasterConnectionString = masterConnectionString; DatabaseName = databaseName; } From 166235a71b1355c14bf97c9978e1893e087f3a7c Mon Sep 17 00:00:00 2001 From: MaddyDev Date: Tue, 9 Jul 2024 13:46:16 -0700 Subject: [PATCH 09/16] add method name to UserFunctionId --- src/TriggerBinding/SqlTriggerBinding.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TriggerBinding/SqlTriggerBinding.cs b/src/TriggerBinding/SqlTriggerBinding.cs index eb1432a40..404de470c 100644 --- a/src/TriggerBinding/SqlTriggerBinding.cs +++ b/src/TriggerBinding/SqlTriggerBinding.cs @@ -107,7 +107,7 @@ private string GetUserFunctionId() string websiteName = SqlBindingUtilities.GetWebSiteName(this._configuration); var methodInfo = (MethodInfo)this._parameter.Member; - string functionName = $"{methodInfo.DeclaringType.Name}"; + string functionName = $"{methodInfo.DeclaringType.Name}.{methodInfo.Name}"; using (var sha256 = SHA256.Create()) { From b12006810426c4aaffc85d22c617cffc7c593446 Mon Sep 17 00:00:00 2001 From: MaddyDev Date: Tue, 9 Jul 2024 23:32:34 -0700 Subject: [PATCH 10/16] remove method name and replace with functionName --- src/TriggerBinding/SqlTriggerBinding.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/TriggerBinding/SqlTriggerBinding.cs b/src/TriggerBinding/SqlTriggerBinding.cs index 404de470c..62db56091 100644 --- a/src/TriggerBinding/SqlTriggerBinding.cs +++ b/src/TriggerBinding/SqlTriggerBinding.cs @@ -107,7 +107,8 @@ private string GetUserFunctionId() string websiteName = SqlBindingUtilities.GetWebSiteName(this._configuration); var methodInfo = (MethodInfo)this._parameter.Member; - string functionName = $"{methodInfo.DeclaringType.Name}.{methodInfo.Name}"; + // Get the function name from FunctionName attribute + string functionName = ((FunctionNameAttribute)methodInfo.GetCustomAttribute(typeof(FunctionNameAttribute))).Name; using (var sha256 = SHA256.Create()) { From 90c9d614d1470a93d7100ea19ab6c522bb8985d1 Mon Sep 17 00:00:00 2001 From: MaddyDev Date: Fri, 12 Jul 2024 11:33:09 -0700 Subject: [PATCH 11/16] update to sdk with latest security patch --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index 757e1346e..649210b26 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "6.0.411", + "version": "6.0.424", "rollForward": "latestFeature" } } \ No newline at end of file From fe64377af1086c89f5a5c76bcbff39325ae3f556 Mon Sep 17 00:00:00 2001 From: MaddyDev Date: Mon, 15 Jul 2024 11:59:50 -0700 Subject: [PATCH 12/16] do not fail on PRs --- builds/azure-pipelines/template-steps-build-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builds/azure-pipelines/template-steps-build-test.yml b/builds/azure-pipelines/template-steps-build-test.yml index 037e86c83..a52555333 100644 --- a/builds/azure-pipelines/template-steps-build-test.yml +++ b/builds/azure-pipelines/template-steps-build-test.yml @@ -280,7 +280,7 @@ steps: - task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0 displayName: 'Component Detection' inputs: - failOnAlert: true + failOnAlert: false - task: securedevelopmentteam.vss-secure-development-tools.build-task-postanalysis.PostAnalysis@2 displayName: 'Post Analysis' From ffa1852c831ab4af0c13ce2ef760288030db1bb6 Mon Sep 17 00:00:00 2001 From: MaddyDev Date: Tue, 16 Jul 2024 00:00:09 -0700 Subject: [PATCH 13/16] argument excepion fix --- test/Common/TestUtils.cs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/test/Common/TestUtils.cs b/test/Common/TestUtils.cs index 04c3b15f8..b3f5fa224 100644 --- a/test/Common/TestUtils.cs +++ b/test/Common/TestUtils.cs @@ -358,18 +358,21 @@ public static DataReceivedEventHandler CreateOutputReceievedHandler(TaskCompleti { return (object sender, DataReceivedEventArgs e) => { - Match match = Regex.Match(e.Data, regex); - if (match.Success) + if (e != null && e.Data != null) { - // We found the line so now check that the group matches our expected value - string actualValue = match.Groups[1].Value; - if (actualValue == expectedValue) + Match match = Regex.Match(e.Data, regex); + if (match.Success) { - taskCompletionSource.SetResult(true); - } - else - { - taskCompletionSource.SetException(new Exception($"Expected {valueName} value of {expectedValue} but got value {actualValue}")); + // We found the line so now check that the group matches our expected value + string actualValue = match.Groups[1].Value; + if (actualValue == expectedValue) + { + taskCompletionSource.SetResult(true); + } + else + { + taskCompletionSource.SetException(new Exception($"Expected {valueName} value of {expectedValue} but got value {actualValue}")); + } } } }; From 6bce289e97548d8998262016bbc566f54f077d4d Mon Sep 17 00:00:00 2001 From: MaddyDev Date: Tue, 16 Jul 2024 00:01:15 -0700 Subject: [PATCH 14/16] undo Component Detection change --- builds/azure-pipelines/template-steps-build-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builds/azure-pipelines/template-steps-build-test.yml b/builds/azure-pipelines/template-steps-build-test.yml index a52555333..037e86c83 100644 --- a/builds/azure-pipelines/template-steps-build-test.yml +++ b/builds/azure-pipelines/template-steps-build-test.yml @@ -280,7 +280,7 @@ steps: - task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0 displayName: 'Component Detection' inputs: - failOnAlert: false + failOnAlert: true - task: securedevelopmentteam.vss-secure-development-tools.build-task-postanalysis.PostAnalysis@2 displayName: 'Post Analysis' From aac4e48797e9c56c8b2f6572d01b066a13b8daac Mon Sep 17 00:00:00 2001 From: MaddyDev Date: Thu, 18 Jul 2024 08:41:10 -0700 Subject: [PATCH 15/16] undo sdk bump --- builds/azure-pipelines/build-pr.yml | 2 +- global.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/builds/azure-pipelines/build-pr.yml b/builds/azure-pipelines/build-pr.yml index 078a4f9d1..c1081afb7 100644 --- a/builds/azure-pipelines/build-pr.yml +++ b/builds/azure-pipelines/build-pr.yml @@ -37,7 +37,7 @@ stages: workspace: clean: all - timeoutInMinutes: '120' + timeoutInMinutes: '90' steps: - template: 'template-steps-build-test.yml' diff --git a/global.json b/global.json index 649210b26..757e1346e 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "6.0.424", + "version": "6.0.411", "rollForward": "latestFeature" } } \ No newline at end of file From 172d07f5df1476e21ecffb88bcc412b726fce36f Mon Sep 17 00:00:00 2001 From: MaddyDev Date: Fri, 19 Jul 2024 16:10:12 -0700 Subject: [PATCH 16/16] fix FunctionName for non .Net --- src/TriggerBinding/SqlTriggerBinding.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/TriggerBinding/SqlTriggerBinding.cs b/src/TriggerBinding/SqlTriggerBinding.cs index 62db56091..326a21276 100644 --- a/src/TriggerBinding/SqlTriggerBinding.cs +++ b/src/TriggerBinding/SqlTriggerBinding.cs @@ -107,8 +107,8 @@ private string GetUserFunctionId() string websiteName = SqlBindingUtilities.GetWebSiteName(this._configuration); var methodInfo = (MethodInfo)this._parameter.Member; - // Get the function name from FunctionName attribute - string functionName = ((FunctionNameAttribute)methodInfo.GetCustomAttribute(typeof(FunctionNameAttribute))).Name; + // Get the function name from FunctionName attribute for .NET functions and methodInfo.Name for non .Net + string functionName = ((FunctionNameAttribute)methodInfo.GetCustomAttribute(typeof(FunctionNameAttribute)))?.Name ?? $"{methodInfo.Name}"; using (var sha256 = SHA256.Create()) {