Skip to content

Commit 0b48f94

Browse files
authored
feat: add Log Analytics workspace and diagnostics for deployment container
- Added a Log Analytics workspace resource to monitor deployment activities. - Implemented diagnostic settings for the deployment container and blob service. - Updated variables for log analytics retention and included options for enabling/disabling log analytics. - Adjusted scale capacity for cognitive deployments to avoid exceeding quotas. - Enhanced troubleshooting documentation for deployment errors and quota issues.
1 parent a5cc734 commit 0b48f94

File tree

10 files changed

+240
-135
lines changed

10 files changed

+240
-135
lines changed

.github/workflows/azure-dev.yml

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ on:
2020
# Set this to the mainline branch you are using
2121
branches:
2222
- main
23+
pull_request:
24+
# Run when pull requests are opened or updated
25+
branches:
26+
- main
2327
# GitHub Actions workflow to deploy to Azure using azd
24-
2528
permissions:
2629
actions: read # Needed for uploading SARIF reports
2730
security-events: write # Needed for uploading SARIF reports
@@ -37,18 +40,16 @@ jobs:
3740
AZURE_LOCATION: ${{ github.event.inputs.azure_location || 'eastus' }}
3841

3942
steps:
40-
- name: Checkout the branch ${{ github.ref_name }}
41-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
42-
with:
43-
ref: ${{ github.ref_name }}
43+
- name: Checkout code
44+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
4445

4546
- name: Install azd
46-
uses: Azure/setup-azd@cf638ffd167fc81e1851241a478a723c05fa9cb3 # v2.2.0
47+
uses: Azure/setup-azd@cf638ffd167fc81e1851241a478a723c05fa9cb3 # v2.2.0
4748
with:
4849
version: '1.20.0' # Specify your desired azd version here
4950

5051
- name: Setup Node.js
51-
uses: actions/setup-node@v5
52+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
5253
with:
5354
node-version: '18.x'
5455

@@ -58,7 +59,7 @@ jobs:
5859
terraform_version: 1.13.3
5960

6061
- name: Install TFLint
61-
uses: terraform-linters/setup-tflint@acd1575d3c037258ce5b2dd01379dc49ce24c6b7 # v6.2.0
62+
uses: terraform-linters/setup-tflint@acd1575d3c037258ce5b2dd01379dc49ce24c6b7 # v6.2.0
6263
with:
6364
tflint_version: v0.58.1
6465
github_token: ${{ secrets.GITHUB_TOKEN }} # Used to avoid rate
@@ -86,9 +87,21 @@ jobs:
8687
echo "GitLeaks scan completed"
8788
8889
- name: Setup .NET SDK
89-
uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5.0.0
90-
with:
91-
dotnet-version: '8.0.x'
90+
shell: bash
91+
run: |
92+
# Install .NET SDK to temp directory for self-hosted runners to avoid permission issues
93+
DOTNET_INSTALL_DIR="${{ runner.temp }}/dotnet"
94+
mkdir -p "$DOTNET_INSTALL_DIR"
95+
96+
# Download and run the dotnet-install script
97+
curl -sSL https://dot.net/v1/dotnet-install.sh -o dotnet-install.sh
98+
chmod +x dotnet-install.sh
99+
./dotnet-install.sh --channel 9.0 --install-dir "$DOTNET_INSTALL_DIR"
100+
rm dotnet-install.sh
101+
102+
# Add to PATH for subsequent steps
103+
echo "$DOTNET_INSTALL_DIR" >> $GITHUB_PATH
104+
echo "DOTNET_ROOT=$DOTNET_INSTALL_DIR" >> $GITHUB_ENV
92105
93106
- name: Install Power Platform Tools
94107
uses: microsoft/powerplatform-actions/actions-install@6c7b538671a040d11afd8ab94d77bfe3b3ed87e6 # v1.9.1
@@ -100,7 +113,7 @@ jobs:
100113
pac help
101114
102115
- name: Set Up Python
103-
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # 6.0.0
116+
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # 6.0.0
104117
with:
105118
python-version: "3.x"
106119

@@ -181,7 +194,7 @@ jobs:
181194
sarif_file: ./checkov-results.sarif/results_sarif.sarif
182195

183196
- name: Azd down
184-
if: ${{ github.event.inputs.run_azd_down == 'true' }}
197+
if: ${{ github.event.inputs.run_azd_down == 'true' || github.event_name == 'pull_request' }}
185198
env:
186199
POWER_PLATFORM_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }}
187200
POWER_PLATFORM_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}

docs/app_registration_setup.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ To enable secure automation and integration with Azure and Power Platform, you n
77
1. Login to your Power Platform:
88

99
```shell
10-
pac auth create
10+
pac auth create --deviceCode
1111
```
1212

1313
1. Create new **App Registration**:

docs/cicd.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ All infrastructure for CI/CD lives under `cicd/` and can be customized to meet y
1313

1414
## Prerequisites
1515

16-
- Working local environment of this template. If you do not have one, Follow the step by step instructions for setting up your [**Local Environment**](../README.md#local-environment)
16+
- Working local environment of this template. If you do not have one, Follow the step by step instructions for setting up your [**Local Environment**](../README.md#local-environment).
1717
- An Azure subscription with either User Access Administrator or Owner permissions to create workload identity resources like service principal, and OIDC to be used by the GitHub Actions.
1818
- GitHub CLI (`gh`) installed and authenticated to trigger the bootstrap workflow from your terminal.
1919

docs/troubleshooting.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Troubleshooting tips
2+
3+
## Quota error during deployment
4+
5+
If you see an InsufficientQuota error mentioning "Tokens Per Minute", the requested `scale.capacity` (thousands of TPM) exceeds your subscription's available quota — lower `scale.capacity` in TFVARS or request a quota increase in the Azure portal.
6+
7+
## Private endpoint fails with AccountProvisioningStateInvalid
8+
9+
This occurs when Terraform tries to create the private endpoint before the Azure OpenAI (Cognitive Services) account leaves the `Accepted` state; wait until the resource shows `Succeeded` (portal or `az resource show`) and re-run the provisioning (`azd provision`).
10+
11+
## Use GitHub Copilot to help troubleshoot
12+
13+
If you're unsure how to fix a deployment error, open the relevant files in VS Code and use GitHub Copilot for suggestions. Copilot can propose TFVARS overrides, sample values, terraform plan snippets, or concise support-request wording; always review and test generated suggestions before applying them.

infra/main.app_insights.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33

44
resource "random_uuid" "uid" {}
55

6+
resource "azurerm_log_analytics_workspace" "monitoring" {
7+
count = var.include_log_analytics ? 1 : 0
8+
9+
daily_quota_gb = -1
10+
location = local.primary_azure_region
11+
name = azurecaf_name.main_names.results["azurerm_log_analytics_workspace"]
12+
resource_group_name = local.resource_group_name
13+
retention_in_days = var.log_analytics_retention_in_days
14+
sku = "PerGB2018"
15+
tags = var.tags
16+
}
17+
618
resource "azurerm_application_insights" "insights" {
719
count = var.include_app_insights ? 1 : 0
820

infra/main.naming.tf

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55

66
locals {
77
# Organization suffixes and prefixes are optional, and we need to form an array of non-empty values only
8-
org_prefix = compact([var.org_naming.org_prefix])
9-
org_suffix = compact([var.org_naming.org_environment, var.org_naming.org_suffix])
8+
org_prefix = compact([var.org_naming.org_prefix])
9+
org_suffix = compact([var.org_naming.org_environment, var.org_naming.org_suffix])
10+
azd_env_seed = parseint(substr(md5(var.azd_environment_name), 0, 8), 16)
1011
}
1112

1213
# Generate unique names for primary resources
@@ -17,6 +18,7 @@ resource "azurecaf_name" "main_names" {
1718
"azurerm_storage_account",
1819
"azurerm_search_service",
1920
"azurerm_cognitive_account",
21+
"azurerm_log_analytics_workspace",
2022
"azurerm_virtual_network",
2123
"azurerm_network_security_group",
2224
"azurerm_virtual_network_gateway",
@@ -25,6 +27,7 @@ resource "azurecaf_name" "main_names" {
2527
prefixes = local.org_prefix
2628
suffixes = local.org_suffix
2729
random_length = 4
30+
random_seed = local.azd_env_seed
2831
# use_slug = false
2932
clean_input = true
3033
}

infra/main.resource_group.tf

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT license.
3+
4+
# Resource Group Configuration and Management
5+
# This file contains resource group resources and related diagnostic settings
6+
7+
# Resource group logic - use existing or create new
8+
locals {
9+
use_existing_resource_group = var.resource_group_name != null && var.resource_group_name != ""
10+
resource_group_name = local.use_existing_resource_group ? var.resource_group_name : azurerm_resource_group.this[0].name
11+
resource_group_id = local.use_existing_resource_group ? data.azurerm_resource_group.existing[0].id : azurerm_resource_group.this[0].id
12+
}
13+
14+
# Data source to validate existing resource group exists
15+
data "azurerm_resource_group" "existing" {
16+
count = local.use_existing_resource_group ? 1 : 0
17+
name = var.resource_group_name
18+
}
19+
20+
# The Resource Group that will contain the resources managed by this module (only created if not using existing)
21+
resource "azurerm_resource_group" "this" {
22+
count = local.use_existing_resource_group ? 0 : 1
23+
location = local.primary_azure_region
24+
name = azurecaf_name.main_names.results["azurerm_resource_group"]
25+
tags = merge(var.tags, local.env_tags)
26+
}

0 commit comments

Comments
 (0)