From 2f1efb2baf9339e757e73ee32754f98c10f74b19 Mon Sep 17 00:00:00 2001 From: brown9804 Date: Wed, 27 Aug 2025 11:59:23 -0600 Subject: [PATCH 1/4] terraform template --- .gitignore | 7 +- README.md | 2 +- AI-Search_Overview.md => aiSearch-Overview.md | 2 +- terraform-infrastructure/main.tf | 125 ++++++++++++++++++ terraform-infrastructure/outputs.tf | 11 ++ terraform-infrastructure/provider.tf | 27 ++++ terraform-infrastructure/terraform.tfvars | 12 ++ terraform-infrastructure/variables.tf | 60 +++++++++ 8 files changed, 240 insertions(+), 6 deletions(-) rename AI-Search_Overview.md => aiSearch-Overview.md (99%) create mode 100644 terraform-infrastructure/main.tf create mode 100644 terraform-infrastructure/outputs.tf create mode 100644 terraform-infrastructure/provider.tf create mode 100644 terraform-infrastructure/terraform.tfvars create mode 100644 terraform-infrastructure/variables.tf diff --git a/.gitignore b/.gitignore index 6349e36..0c5e84e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ # Local .terraform directories -.terraform/ +*.terraform** # .tfstate files *.tfstate @@ -13,7 +13,6 @@ crash.*.log # password, private keys, and other secrets. These should not be part of version # control as they are data points which are potentially sensitive and subject # to change depending on the environment. -*.tfvars *.tfvars.json # Ignore override files as they are usually used to override resources locally and so @@ -25,7 +24,7 @@ override.tf.json # Ignore transient lock info files created by terraform apply .terraform.tfstate.lock.info - +.terraform.lock.hcl # Include override files you do wish to add to version control using negated pattern # !example_override.tf @@ -34,4 +33,4 @@ override.tf.json # Ignore CLI configuration files .terraformrc -terraform.rc +terraform.rc \ No newline at end of file diff --git a/README.md b/README.md index fa49d5a..c4df88e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Azure Text Embedding Model Recommendations - Overview +# Azure Text Embedding Model - Overview Costa Rica diff --git a/AI-Search_Overview.md b/aiSearch-Overview.md similarity index 99% rename from AI-Search_Overview.md rename to aiSearch-Overview.md index 176238a..cd7eaa0 100644 --- a/AI-Search_Overview.md +++ b/aiSearch-Overview.md @@ -1,4 +1,4 @@ -# RAG (Retrieval-Augmented Generation) pattern - Overview +# Azure AI Search - Overview Costa Rica diff --git a/terraform-infrastructure/main.tf b/terraform-infrastructure/main.tf new file mode 100644 index 0000000..6403708 --- /dev/null +++ b/terraform-infrastructure/main.tf @@ -0,0 +1,125 @@ +// Retrieve client config – helpful for role assignments. +data "azurerm_client_config" "example" {} + +// Optionally, retrieve your own Azure AD user info. +data "azuread_user" "current" { + object_id = data.azurerm_client_config.example.object_id +} + +// Resource Group +resource "azurerm_resource_group" "rg" { + name = var.resource_group_name + location = var.location + tags = { + Project = "AI Agents" + } +} + +// Key Vault +resource "azurerm_key_vault" "example" { + name = var.keyvault_name + location = azurerm_resource_group.rg.location + resource_group_name = azurerm_resource_group.rg.name + tenant_id = data.azurerm_client_config.example.tenant_id + + sku_name = "standard" + purge_protection_enabled = true +} + +// Key Vault Policies +resource "azurerm_key_vault_access_policy" "example" { + key_vault_id = azurerm_key_vault.example.id + tenant_id = data.azurerm_client_config.example.tenant_id + object_id = data.azurerm_client_config.example.object_id + + key_permissions = [ + "Create", + "Get", + "Delete", + "Purge", + "GetRotationPolicy", + ] +} + +// Storage Account +resource "azurerm_storage_account" "example" { + name = var.storage_account_name + location = azurerm_resource_group.rg.location + resource_group_name = azurerm_resource_group.rg.name + account_tier = "Standard" + account_replication_type = "LRS" +} + +// AI Services Account +resource "azurerm_ai_services" "aiserviceaccount" { + name = var.aiservices_name + location = azurerm_resource_group.rg.location + resource_group_name = azurerm_resource_group.rg.name + sku_name = "S0" +} + +// AI Foundry +resource "azurerm_ai_foundry" "aifoundry" { + name = var.aifoundry_name + location = azurerm_ai_services.aiserviceaccount.location + resource_group_name = azurerm_ai_services.aiserviceaccount.resource_group_name + storage_account_id = azurerm_storage_account.example.id + key_vault_id = azurerm_key_vault.example.id + + identity { + type = "SystemAssigned" + } + +} + +// AI Foundry Project +resource "azurerm_ai_foundry_project" "aiproject" { + name = var.aifoundryproject_name + location = azurerm_ai_foundry.aifoundry.location + ai_services_hub_id = azurerm_ai_foundry.aifoundry.id + + identity { + type = "SystemAssigned" + } +} + + +// Azure Open AI (Cognitive Services) Account +resource "azurerm_cognitive_account" "openai" { + name = var.openai_account_name + location = azurerm_resource_group.rg.location + resource_group_name = azurerm_resource_group.rg.name + sku_name = "S0" + kind = "OpenAI" + tags = { + Project = "AI Agents" + } +} + +// Azure Cognitive Search Service +resource "azurerm_search_service" "search" { + name = var.search_service_name + location = azurerm_resource_group.rg.location + resource_group_name = azurerm_resource_group.rg.name + sku = "standard" + partition_count = 1 + replica_count = 1 + tags = { + Project = "AI Agents" + } +} + + +// Role Assignments for Permissions +resource "azurerm_role_assignment" "ai_developer" { + principal_id = var.developer_principal_id # or object_id + scope = azurerm_resource_group.rg.id + role_definition_name = "Azure AI Developer" +} + +resource "azurerm_role_assignment" "openai_user" { + principal_id = var.openai_user_object_id # or we can use object_id + scope = azurerm_resource_group.rg.id + role_definition_name = "Cognitive Services OpenAI User" +} + diff --git a/terraform-infrastructure/outputs.tf b/terraform-infrastructure/outputs.tf new file mode 100644 index 0000000..3fed4e2 --- /dev/null +++ b/terraform-infrastructure/outputs.tf @@ -0,0 +1,11 @@ +output "resource_group_id" { + value = azurerm_resource_group.rg.id +} + +output "openai_account_id" { + value = azurerm_cognitive_account.openai.id +} + +output "search_service_name" { + value = azurerm_search_service.search.name +} \ No newline at end of file diff --git a/terraform-infrastructure/provider.tf b/terraform-infrastructure/provider.tf new file mode 100644 index 0000000..ccafe74 --- /dev/null +++ b/terraform-infrastructure/provider.tf @@ -0,0 +1,27 @@ +# provider.tf +# This file configures the Azure provider to interact with Azure resources. +# It specifies the required provider and its version, along with provider-specific configurations. + +terraform { + required_version = ">= 1.8, < 2.0" + # Specify the required provider and its version + required_providers { + azurerm = { + source = "hashicorp/azurerm" # Source of the AzureRM provider + version = "~> 4.30.0" # Version of the AzureRM provider + } + azuread = { + source = "hashicorp/azuread" + version = "~> 2.38.0" + } + } +} + +provider "azurerm" { + features {} # Enable all features for the AzureRM provider + subscription_id = var.subscription_id # Add your subscription ID here +} + +provider "azuread" { + # Defaults are usually sufficient. +} \ No newline at end of file diff --git a/terraform-infrastructure/terraform.tfvars b/terraform-infrastructure/terraform.tfvars new file mode 100644 index 0000000..2d22808 --- /dev/null +++ b/terraform-infrastructure/terraform.tfvars @@ -0,0 +1,12 @@ +subscription_id = "" +resource_group_name = "RG-Embedding-Btest" +location = "East US" +storage_account_name = "aiembeddingbx1" +aiservices_name = "aiservicesbx1" +keyvault_name = "aiembeddingkvbx1" +aifoundry_name = "aifoundrytestbx1" +aifoundryproject_name = "projectnametestbx1" +openai_account_name = "aoaibx1test" +search_service_name = "aisearchbx1test" +developer_principal_id = "" +openai_user_object_id = "" \ No newline at end of file diff --git a/terraform-infrastructure/variables.tf b/terraform-infrastructure/variables.tf new file mode 100644 index 0000000..1ca87d7 --- /dev/null +++ b/terraform-infrastructure/variables.tf @@ -0,0 +1,60 @@ +variable "subscription_id" { + description = "Azure subscription ID" + type = string +} + +variable "location" { + description = "Azure region" + type = string + default = "East US" +} + +variable "resource_group_name" { + description = "Name of the resource group for the AI Foundry Project" + type = string +} + +variable "keyvault_name" { + description = "The name of the key vault" + type = string +} + +variable "aiservices_name" { + description = "The name of the AI services account" + type = string +} + +variable "aifoundry_name" { + description = "The name of the AI Foundry Hub" + type = string +} + +variable "aifoundryproject_name" { + description = "The name of the AI Foundry Project" + type = string +} + +variable "storage_account_name" { + description = "The name of the storage account" + type = string +} + +variable "openai_account_name" { + description = "Name of the Azure OpenAI (Cognitive Services) account" + type = string +} + +variable "search_service_name" { + description = "Name of the Azure Cognitive Search service" + type = string +} + +variable "developer_principal_id" { + description = "Principal ID for the Azure AI Developer (assigned at the resource group level)" + type = string +} + +variable "openai_user_object_id" { + description = "Object ID for the Cognitive Services Open AI User (assigned at the resource group level)" + type = string +} \ No newline at end of file From 563605ecea352337b0d8def537f4ccb7ad68d6d8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 27 Aug 2025 17:59:56 +0000 Subject: [PATCH 2/4] Update last modified date in Markdown files --- README.md | 2 +- aiSearch-Overview.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c4df88e..c10be61 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Costa Rica [![GitHub](https://img.shields.io/badge/--181717?logo=github&logoColor=ffffff)](https://github.com/) [brown9804](https://github.com/brown9804) -Last updated: 2025-08-20 +Last updated: 2025-08-27 ----------------------------- diff --git a/aiSearch-Overview.md b/aiSearch-Overview.md index cd7eaa0..0bf2914 100644 --- a/aiSearch-Overview.md +++ b/aiSearch-Overview.md @@ -6,7 +6,7 @@ Costa Rica [![GitHub](https://img.shields.io/badge/--181717?logo=github&logoColor=ffffff)](https://github.com/) [brown9804](https://github.com/brown9804) -Last updated: 2025-07-17 +Last updated: 2025-08-27 ---------- From 23dcc23536144872e2b9c218dd20596b98b42397 Mon Sep 17 00:00:00 2001 From: Timna Brown <24630902+brown9804@users.noreply.github.com> Date: Wed, 27 Aug 2025 12:01:25 -0600 Subject: [PATCH 3/4] Refactor visitor counter update logic in workflow Refactor commit and push logic for visitor counter updates to streamline handling for both PR and non-PR events. --- .github/workflows/use-visitor-counter.yml | 42 ++++++++++------------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/.github/workflows/use-visitor-counter.yml b/.github/workflows/use-visitor-counter.yml index b865948..973fb24 100644 --- a/.github/workflows/use-visitor-counter.yml +++ b/.github/workflows/use-visitor-counter.yml @@ -21,6 +21,7 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + ref: ${{ github.head_ref || github.ref_name }} - name: Shallow clone visitor counter logic run: git clone --depth=1 https://github.com/brown9804/github-visitor-counter.git @@ -57,30 +58,23 @@ jobs: git config --global user.name "github-actions[bot]" git config --global user.email "github-actions[bot]@users.noreply.github.com" - # Commit and push logic for PR events (merge, not rebase) - - name: Commit and push changes (PR) - if: github.event_name == 'pull_request' + - name: Commit and merge changes env: - TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_BRANCH: ${{ github.head_ref || github.ref_name }} + GIT_AUTHOR_NAME: github-actions[bot] + GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com + GIT_COMMITTER_NAME: github-actions[bot] + GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com run: | - git fetch origin - git checkout ${{ github.head_ref }} - git pull origin ${{ github.head_ref }} || echo "No merge needed" + # Ensure we're on the correct branch + git switch -c "$PR_BRANCH" || git switch "$PR_BRANCH" + + # Stage and commit changes if any git add -A - git commit -m "Update visitor count" || echo "No changes to commit" - git remote set-url origin https://x-access-token:${TOKEN}@github.com/${{ github.repository }} - git push origin HEAD:${{ github.head_ref }} - - # Commit and push logic for non-PR events (merge, not rebase) - - name: Commit and push changes (non-PR) - if: github.event_name != 'pull_request' - env: - TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - git fetch origin - git checkout ${{ github.ref_name }} || git checkout -b ${{ github.ref_name }} origin/${{ github.ref_name }} - git pull origin ${{ github.ref_name }} || echo "No merge needed" - git add -A - git commit -m "Update visitor count" || echo "No changes to commit" - git remote set-url origin https://x-access-token:${TOKEN}@github.com/${{ github.repository }} - git push origin HEAD:${{ github.ref_name }} + git diff --staged --quiet || git commit -m "Update visitor count" + + # Pull and merge existing changes + git pull origin "$PR_BRANCH" --no-rebase + + # Push all changes + git push origin "$PR_BRANCH" From b8f9f4d11af0afd59e8859e97457b8053923afe6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 27 Aug 2025 18:01:39 +0000 Subject: [PATCH 4/4] Update visitor count --- README.md | 2 +- aiSearch-Overview.md | 2 +- terraform-infrastructure/README.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c10be61..5904db7 100644 --- a/README.md +++ b/README.md @@ -161,7 +161,7 @@ Last updated: 2025-08-27
- Total views + Total views

Refresh Date: 2025-08-27

diff --git a/aiSearch-Overview.md b/aiSearch-Overview.md index 0bf2914..5eee221 100644 --- a/aiSearch-Overview.md +++ b/aiSearch-Overview.md @@ -376,7 +376,7 @@ Click [here](https://github.com/brown9804/MicrosoftCloudEssentialsHub/tree/main/
- Total views + Total views

Refresh Date: 2025-08-27

diff --git a/terraform-infrastructure/README.md b/terraform-infrastructure/README.md index e629ff3..cf1ffb0 100644 --- a/terraform-infrastructure/README.md +++ b/terraform-infrastructure/README.md @@ -133,7 +133,7 @@ graph TD;
- Total views + Total views

Refresh Date: 2025-08-27