Skip to content

Commit 265e619

Browse files
authored
Merge branch 'main' into dependabot/pip/pytest-approx-eq-8.0.0
2 parents 53b7d58 + 951054c commit 265e619

File tree

9 files changed

+60
-43
lines changed

9 files changed

+60
-43
lines changed

.github/workflows/_containerTemplate.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454

5555
# Install cosign
5656
- name: Install cosign
57-
uses: sigstore/cosign-installer@v3.3.0
57+
uses: sigstore/cosign-installer@v3.4.0
5858
id: install_cosign
5959
if: github.event_name == 'release'
6060
with:
@@ -83,7 +83,7 @@ jobs:
8383
# Extract Metadata (tags, labels)
8484
- name: Extract Metadata
8585
id: metadata
86-
uses: docker/metadata-action@v5.5.0
86+
uses: docker/metadata-action@v5.5.1
8787
with:
8888
context: workflow
8989
images: |

.github/workflows/functionApp.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@ on:
66
paths:
77
- "**.py"
88
- "code/function/**"
9+
- "tests/**"
10+
- "requirements.txt"
911

1012
pull_request:
1113
branches:
1214
- main
1315
paths:
1416
- "**.py"
1517
- "code/function/**"
18+
- "tests/**"
19+
- "requirements.txt"
1620

1721
jobs:
1822
function_test:

code/function/fastapp/core/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class Settings(BaseSettings):
2121
WEBSITE_AUTH_ENCRYPTION_KEY: str = Field(
2222
default="", alias="WEBSITE_AUTH_ENCRYPTION_KEY"
2323
)
24+
WEBSITE_OS_TYPE: str = Field(default="test", alias="WEBSITE_OS_TYPE")
2425
MY_SECRET_CONFIG: str = Field(default="", alias="MY_SECRET_CONFIG")
2526

2627

code/function/fastapp/health/validate_request.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,28 @@
44

55
from fastapi import Header, HTTPException
66
from fastapp.core.config import settings
7+
from fastapp.utils import setup_logging
8+
9+
logger = setup_logging(__name__)
710

811

912
async def verify_health_auth_header(
10-
x_ms_auth_internal_token: Annotated[str, Header()]
13+
x_ms_auth_internal_token: Annotated[str | None, Header()] = None
1114
) -> bool:
1215
"""Returns true if SHA256 of header_value matches WEBSITE_AUTH_ENCRYPTION_KEY.
16+
This only works on Windows-based app services. Therefore, this feature is turned off for other OS types.
1317
Documentation: https://learn.microsoft.com/en-us/azure/app-service/monitor-instances-health-check?tabs=python#authentication-and-security
1418
1519
x_ms_auth_internal_token: Value of the x-ms-auth-internal-token header.
1620
RETURNS (bool): Specifies whether the header matches.
1721
"""
18-
website_auth_encryption_key = settings.WEBSITE_AUTH_ENCRYPTION_KEY
19-
hash = base64.b64encode(
20-
sha256(website_auth_encryption_key.encode("utf-8")).digest()
21-
).decode("utf-8")
22-
if hash != x_ms_auth_internal_token:
23-
raise HTTPException(
24-
status_code=400, detail="x-ms-auth-internal-token is invalid"
25-
)
26-
else:
27-
return True
22+
if settings.WEBSITE_OS_TYPE.lower() == "windows":
23+
website_auth_encryption_key = settings.WEBSITE_AUTH_ENCRYPTION_KEY
24+
hash = base64.b64encode(
25+
sha256(website_auth_encryption_key.encode("utf-8")).digest()
26+
).decode("utf-8")
27+
if hash != x_ms_auth_internal_token:
28+
raise HTTPException(
29+
status_code=400, detail="x-ms-auth-internal-token is invalid"
30+
)
31+
return True

code/function/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
# azure-identity~=1.15.0
66
azure-functions~=1.18.0
7-
fastapi~=0.109.0
7+
fastapi~=0.109.1
88
pydantic-settings~=2.1.0
99
httpx~=0.26.0
10-
azure-monitor-opentelemetry-exporter==1.0.0b20
10+
azure-monitor-opentelemetry-exporter==1.0.0b22
1111
opentelemetry-instrumentation-fastapi==0.43b0
1212
opentelemetry-instrumentation-httpx~=0.43b0
1313
opentelemetry-instrumentation-system-metrics~=0.43b0

code/infra/function.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ resource "azapi_resource" "function" {
121121
name = "WEBSITE_CONTENTOVERVNET"
122122
value = "1"
123123
},
124+
{
125+
name = "WEBSITE_OS_TYPE"
126+
value = azurerm_service_plan.service_plan.os_type
127+
},
124128
{
125129
name = "WEBSITE_RUN_FROM_PACKAGE"
126130
value = "0"

code/infra/logging.tf

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,32 @@ resource "azurerm_application_insights" "application_insights" {
1616
workspace_id = azurerm_log_analytics_workspace.log_analytics_workspace.id
1717
}
1818

19-
data "azurerm_monitor_diagnostic_categories" "diagnostic_categories_application_insights" {
20-
resource_id = azurerm_application_insights.application_insights.id
21-
}
22-
23-
resource "azurerm_monitor_diagnostic_setting" "diagnostic_setting_application_insights" {
24-
name = "logAnalytics"
25-
target_resource_id = azurerm_application_insights.application_insights.id
26-
log_analytics_workspace_id = azurerm_log_analytics_workspace.log_analytics_workspace.id
27-
28-
dynamic "enabled_log" {
29-
iterator = entry
30-
for_each = data.azurerm_monitor_diagnostic_categories.diagnostic_categories_application_insights.log_category_groups
31-
content {
32-
category_group = entry.value
33-
}
34-
}
35-
36-
dynamic "metric" {
37-
iterator = entry
38-
for_each = data.azurerm_monitor_diagnostic_categories.diagnostic_categories_application_insights.metrics
39-
content {
40-
category = entry.value
41-
enabled = true
42-
}
43-
}
44-
}
19+
# data "azurerm_monitor_diagnostic_categories" "diagnostic_categories_application_insights" { # Disable to avoid duplicate logs in Application Insights
20+
# resource_id = azurerm_application_insights.application_insights.id
21+
# }
22+
23+
# resource "azurerm_monitor_diagnostic_setting" "diagnostic_setting_application_insights" {
24+
# name = "logAnalytics"
25+
# target_resource_id = azurerm_application_insights.application_insights.id
26+
# log_analytics_workspace_id = azurerm_log_analytics_workspace.log_analytics_workspace.id
27+
28+
# dynamic "enabled_log" {
29+
# iterator = entry
30+
# for_each = data.azurerm_monitor_diagnostic_categories.diagnostic_categories_application_insights.log_category_groups
31+
# content {
32+
# category_group = entry.value
33+
# }
34+
# }
35+
36+
# dynamic "metric" {
37+
# iterator = entry
38+
# for_each = data.azurerm_monitor_diagnostic_categories.diagnostic_categories_application_insights.metrics
39+
# content {
40+
# category = entry.value
41+
# enabled = true
42+
# }
43+
# }
44+
# }
4545

4646
resource "azurerm_log_analytics_workspace" "log_analytics_workspace" {
4747
name = "${local.prefix}-log001"

code/infra/storage.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ resource "azurerm_storage_account" "storage" {
3434
default_action = "Deny"
3535
ip_rules = []
3636
virtual_network_subnet_ids = []
37+
private_link_access {
38+
endpoint_resource_id = "/subscriptions/${data.azurerm_client_config.current.subscription_id}/providers/Microsoft.Security/datascanners/storageDataScanner"
39+
endpoint_tenant_id = data.azurerm_client_config.current.tenant_id
40+
}
3741
}
3842
nfsv3_enabled = false
3943
public_network_access_enabled = false

code/infra/terraform.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ terraform {
44
required_providers {
55
azurerm = {
66
source = "hashicorp/azurerm"
7-
version = "3.87.0"
7+
version = "3.90.0"
88
}
99
azapi = {
1010
source = "azure/azapi"
11-
version = "1.11.0"
11+
version = "1.12.0"
1212
}
1313
}
1414

0 commit comments

Comments
 (0)