We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Application Insights configuration for processor function broken
The `createNewWorkspace` function monitoring blade indicates that Application Insights integration is not enabled.
![image](https://user-images.githubusercontent.com/166592/123793166-b7edfa80-d8e1-11eb-8906-b4175f4348e0.png)

At a first glance, the config seems to be there in [processor_function/function.tf](https://github.com/microsoft/AzureTRE/blob/develop/templates/core/terraform/processor_function/function.tf#L24)
```plaintext
    APP_INSIGHTS_INSTRUMENTATION_KEY      = var.app_insights_instrumentation_key
```
however, the setting key name is incorrect.

Manually enabling the integration in the portal adds additional config keys:

`APPLICATIONINSIGHTS_CONNECTION_STRING`
`APPINSIGHTS_INSTRUMENTATIONKEY`

Need to add above keys with values to function app config.

[Reference](https://docs.microsoft.com/en-us/azure/azure-monitor/app/resource-manager-function-app)

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `processor_function/shared/logging.py`
Content:
```
1 import logging
2 import os
3 
4 from opencensus.ext.azure.log_exporter import AzureLogHandler
5 from opencensus.trace import config_integration
6 from opencensus.trace.samplers import AlwaysOnSampler
7 from opencensus.trace.tracer import Tracer
8 
9 
10 def initialize_logging(logging_level: int, correlation_id: str) -> logging.LoggerAdapter:
11     """
12     Adds the Application Insights handler for the root logger and sets the given logging level.
13     Creates and returns a logger adapter that integrates the correlation ID, if given, to the log messages.
14 
15     :param logging_level: The logging level to set e.g., logging.WARNING.
16     :param correlation_id: Optional. The correlation ID that is passed on to the operation_Id in App Insights.
17     :returns: A newly created logger adapter.
18     """
19     logger = logging.getLogger()
20     logger.addHandler(logging.StreamHandler())  # For logging into console
21     app_insights_instrumentation_key = os.getenv("APP_INSIGHTS_INSTRUMENTATION_KEY")
22 
23     try:
24         logger.addHandler(AzureLogHandler(connection_string=f"InstrumentationKey={app_insights_instrumentation_key}"))
25     except ValueError as e:
26         logger.error(f"Failed to set Application Insights logger handler: {e}")
27 
28     config_integration.trace_integrations(['logging'])
29     logging.basicConfig(level=logging_level, format='%(asctime)s traceId=%(traceId)s spanId=%(spanId)s %(message)s')
30     Tracer(sampler=AlwaysOnSampler())
31     logger.setLevel(logging_level)
32 
33     extra = None
34 
35     if correlation_id:
36         extra = {'traceId': correlation_id}
37 
38     adapter = logging.LoggerAdapter(logger, extra)
39     adapter.debug(f"Logger adapter initialized with extra: {extra}")
40 
41     return adapter
42
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/processor_function/shared/logging.py b/processor_function/shared/logging.py
--- a/processor_function/shared/logging.py
+++ b/processor_function/shared/logging.py
@@ -18,10 +18,10 @@
     """
     logger = logging.getLogger()
     logger.addHandler(logging.StreamHandler())  # For logging into console
-    app_insights_instrumentation_key = os.getenv("APP_INSIGHTS_INSTRUMENTATION_KEY")
+    app_insights_connection_string = os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING")
 
     try:
-        logger.addHandler(AzureLogHandler(connection_string=f"InstrumentationKey={app_insights_instrumentation_key}"))
+        logger.addHandler(AzureLogHandler(connection_string=app_insights_connection_string))
     except ValueError as e:
         logger.error(f"Failed to set Application Insights logger handler: {e}")

{"golden_diff": "diff --git a/processor_function/shared/logging.py b/processor_function/shared/logging.py\n--- a/processor_function/shared/logging.py\n+++ b/processor_function/shared/logging.py\n@@ -18,10 +18,10 @@\n     \"\"\"\n     logger = logging.getLogger()\n     logger.addHandler(logging.StreamHandler())  # For logging into console\n-    app_insights_instrumentation_key = os.getenv(\"APP_INSIGHTS_INSTRUMENTATION_KEY\")\n+    app_insights_connection_string = os.getenv(\"APPLICATIONINSIGHTS_CONNECTION_STRING\")\n \n     try:\n-        logger.addHandler(AzureLogHandler(connection_string=f\"InstrumentationKey={app_insights_instrumentation_key}\"))\n+        logger.addHandler(AzureLogHandler(connection_string=app_insights_connection_string))\n     except ValueError as e:\n         logger.error(f\"Failed to set Application Insights logger handler: {e}\")\n", "issue": "Application Insights configuration for processor function broken\nThe `createNewWorkspace` function monitoring blade indicates that Application Insights integration is not enabled.\r\n![image](https://user-images.githubusercontent.com/166592/123793166-b7edfa80-d8e1-11eb-8906-b4175f4348e0.png)\r\n\r\nAt a first glance, the config seems to be there in [processor_function/function.tf](https://github.com/microsoft/AzureTRE/blob/develop/templates/core/terraform/processor_function/function.tf#L24)\r\n```plaintext\r\n    APP_INSIGHTS_INSTRUMENTATION_KEY      = var.app_insights_instrumentation_key\r\n```\r\nhowever, the setting key name is incorrect.\r\n\r\nManually enabling the integration in the portal adds additional config keys:\r\n\r\n`APPLICATIONINSIGHTS_CONNECTION_STRING`\r\n`APPINSIGHTS_INSTRUMENTATIONKEY`\r\n\r\nNeed to add above keys with values to function app config.\r\n\r\n[Reference](https://docs.microsoft.com/en-us/azure/azure-monitor/app/resource-manager-function-app)\n", "before_files": [{"content": "import logging\nimport os\n\nfrom opencensus.ext.azure.log_exporter import AzureLogHandler\nfrom opencensus.trace import config_integration\nfrom opencensus.trace.samplers import AlwaysOnSampler\nfrom opencensus.trace.tracer import Tracer\n\n\ndef initialize_logging(logging_level: int, correlation_id: str) -> logging.LoggerAdapter:\n    \"\"\"\n    Adds the Application Insights handler for the root logger and sets the given logging level.\n    Creates and returns a logger adapter that integrates the correlation ID, if given, to the log messages.\n\n    :param logging_level: The logging level to set e.g., logging.WARNING.\n    :param correlation_id: Optional. The correlation ID that is passed on to the operation_Id in App Insights.\n    :returns: A newly created logger adapter.\n    \"\"\"\n    logger = logging.getLogger()\n    logger.addHandler(logging.StreamHandler())  # For logging into console\n    app_insights_instrumentation_key = os.getenv(\"APP_INSIGHTS_INSTRUMENTATION_KEY\")\n\n    try:\n        logger.addHandler(AzureLogHandler(connection_string=f\"InstrumentationKey={app_insights_instrumentation_key}\"))\n    except ValueError as e:\n        logger.error(f\"Failed to set Application Insights logger handler: {e}\")\n\n    config_integration.trace_integrations(['logging'])\n    logging.basicConfig(level=logging_level, format='%(asctime)s traceId=%(traceId)s spanId=%(spanId)s %(message)s')\n    Tracer(sampler=AlwaysOnSampler())\n    logger.setLevel(logging_level)\n\n    extra = None\n\n    if correlation_id:\n        extra = {'traceId': correlation_id}\n\n    adapter = logging.LoggerAdapter(logger, extra)\n    adapter.debug(f\"Logger adapter initialized with extra: {extra}\")\n\n    return adapter\n", "path": "processor_function/shared/logging.py"}], "after_files": [{"content": "import logging\nimport os\n\nfrom opencensus.ext.azure.log_exporter import AzureLogHandler\nfrom opencensus.trace import config_integration\nfrom opencensus.trace.samplers import AlwaysOnSampler\nfrom opencensus.trace.tracer import Tracer\n\n\ndef initialize_logging(logging_level: int, correlation_id: str) -> logging.LoggerAdapter:\n    \"\"\"\n    Adds the Application Insights handler for the root logger and sets the given logging level.\n    Creates and returns a logger adapter that integrates the correlation ID, if given, to the log messages.\n\n    :param logging_level: The logging level to set e.g., logging.WARNING.\n    :param correlation_id: Optional. The correlation ID that is passed on to the operation_Id in App Insights.\n    :returns: A newly created logger adapter.\n    \"\"\"\n    logger = logging.getLogger()\n    logger.addHandler(logging.StreamHandler())  # For logging into console\n    app_insights_connection_string = os.getenv(\"APPLICATIONINSIGHTS_CONNECTION_STRING\")\n\n    try:\n        logger.addHandler(AzureLogHandler(connection_string=app_insights_connection_string))\n    except ValueError as e:\n        logger.error(f\"Failed to set Application Insights logger handler: {e}\")\n\n    config_integration.trace_integrations(['logging'])\n    logging.basicConfig(level=logging_level, format='%(asctime)s traceId=%(traceId)s spanId=%(spanId)s %(message)s')\n    Tracer(sampler=AlwaysOnSampler())\n    logger.setLevel(logging_level)\n\n    extra = None\n\n    if correlation_id:\n        extra = {'traceId': correlation_id}\n\n    adapter = logging.LoggerAdapter(logger, extra)\n    adapter.debug(f\"Logger adapter initialized with extra: {extra}\")\n\n    return adapter\n", "path": "processor_function/shared/logging.py"}]}