Skip to content

Commit dd8e853

Browse files
Fallback to Host ID if WEBSITE_SITE_NAME isn't defined (#1178)
* Fall back to using Host ID if WEBSITE_SITE_NAME doesn't exist * cleanup * Pass in env vars to startup * verify test fails * try * remove default site name settings * Update comment * update docs
1 parent 7e44445 commit dd8e853

File tree

17 files changed

+83
-72
lines changed

17 files changed

+83
-72
lines changed

docs/BindingsOverview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
- [Sql\_Trigger\_MaxBatchSize](#sql_trigger_maxbatchsize)
2121
- [Sql\_Trigger\_PollingIntervalMs](#sql_trigger_pollingintervalms)
2222
- [Sql\_Trigger\_MaxChangesPerWorker](#sql_trigger_maxchangesperworker)
23+
- [WEBSITE\_SITE\_NAME](#website_site_name)
2324
- [Scaling for Trigger Bindings](#scaling-for-trigger-bindings)
2425
- [Retry support for Trigger Bindings](#retry-support-for-trigger-bindings)
2526
- [Startup retries](#startup-retries)
@@ -154,11 +155,10 @@ The upper limit on the number of pending changes in the user table that are allo
154155

155156
#### WEBSITE_SITE_NAME
156157

157-
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.
158+
If this setting exists, it will be used to generate a unique identifier for the function that is used for tracking function state. If not specified, this unique identifier will be generated from the [IHostIdProvider.GetHostIdAsync](https://github.com/Azure/azure-webjobs-sdk/blob/dev/src/Microsoft.Azure.WebJobs.Host/Executors/IHostIdProvider.cs#L14).
158159

159160
> **NOTE:**
160161
> * If the setting is re-used across 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.
161-
> * 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.
162162
> * This is a read-only variable that is provided by the Azure App service 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.
163163

164164
### Scaling for Trigger Bindings

docs/TriggerBinding.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,12 @@ To find the name of the leases table associated with your function, look in the
9696

9797
This log message is at the `Information` level, so make sure your log level is set correctly.
9898

99-
NOTE: `FunctionId` is generated from a couple of inputs:
100-
- The [WEBSITE_SITE_NAME](https://github.com/Azure/azure-functions-sql-extension/blob/main/docs/BindingsOverview.md#website_site_name) setting
101-
- The name of the function
99+
NOTE: `FunctionId` is generated from the name of the function and either
102100

103-
If either of these values are changed then a new FunctionId will be generated and result in the function starting over from the beginning, including creating a new Leases table.
101+
* The [WEBSITE_SITE_NAME](https://github.com/Azure/azure-functions-sql-extension/blob/main/docs/BindingsOverview.md#website_site_name) setting
102+
* [IHostIdProvider.GetHostIdAsync](https://github.com/Azure/azure-webjobs-sdk/blob/dev/src/Microsoft.Azure.WebJobs.Host/Executors/IHostIdProvider.cs#L14) as a fallback if the WEBSITE_SITE_NAME setting doesn't exist
103+
104+
If either the name of the function or the `WEBSITE_SITE_NAME`/`GetHostIdAsync` values are changed then a new FunctionId will be generated and result in the function starting over from the beginning, including creating a new Leases table.
104105

105106
This table is used to ensure that all changes are processed and that no change is processed more than once. This table consists of two groups of columns:
106107

samples/samples-csharp/local.settings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
55
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
66
"SqlConnectionString": "",
7-
"WEBSITE_SITE_NAME": "SamplesCSharp",
87
"Sp_SelectCost": "SelectProductsCost",
98
"ProductCost": 100
109
}

samples/samples-csx/local.settings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
55
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
66
"SqlConnectionString": "",
7-
"WEBSITE_SITE_NAME": "SamplesCsx",
87
"Sp_SelectCost": "SelectProductsCost",
98
"ProductCost": 100
109
}

samples/samples-java/local.settings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
55
"FUNCTIONS_WORKER_RUNTIME": "java",
66
"SqlConnectionString": "",
7-
"WEBSITE_SITE_NAME": "SamplesJava",
87
"Sp_SelectCost": "SelectProductsCost",
98
"ProductCost": 100
109
}

samples/samples-js-v4/local.settings.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
55
"FUNCTIONS_WORKER_RUNTIME": "node",
66
"AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
7-
"SqlConnectionString": "",
8-
"WEBSITE_SITE_NAME": "SamplesNodeV4"
7+
"SqlConnectionString": ""
98
}
109
}

samples/samples-js/local.settings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
55
"FUNCTIONS_WORKER_RUNTIME": "node",
66
"SqlConnectionString": "",
7-
"WEBSITE_SITE_NAME": "SamplesJavascript",
87
"Sp_SelectCost": "SelectProductsCost",
98
"ProductCost": 100
109
}

samples/samples-outofproc/local.settings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
55
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
66
"SqlConnectionString": "",
7-
"WEBSITE_SITE_NAME": "SamplesOOP",
87
"Sp_SelectCost": "SelectProductsCost",
98
"ProductCost": 100
109
}

samples/samples-powershell/local.settings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"FUNCTIONS_WORKER_RUNTIME": "powershell",
66
"FUNCTIONS_WORKER_RUNTIME_VERSION" : "~7.2",
77
"SqlConnectionString": "",
8-
"WEBSITE_SITE_NAME": "SamplesPowershell",
98
"Sp_SelectCost": "SelectProductsCost",
109
"ProductCost": 100
1110
}

samples/samples-python-v2/local.settings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
66
"AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
77
"SqlConnectionString": "",
8-
"WEBSITE_SITE_NAME": "SamplesPythonV2",
98
"PYTHON_ISOLATE_WORKER_DEPENDENCIES": "1"
109
}
1110
}

0 commit comments

Comments
 (0)