Skip to content

Commit a7b7ecd

Browse files
Eliminates the Terraform workflow for remote state setup, which is no longer needed.
Updates documentation to clarify the configuration for GitHub runners, ensuring users have accurate guidance for setting up and using self-hosted runners effectively. This streamlines the CI/CD process and removes potential confusion for new users. Update Gitleaks scanning for newly initialized templates with no remote branch set. update gitignore to avoid including sensitive data in cicd/.ssh/ cicd/.ssh/* as terraform backend and GH runner code will be executed locally per the updated guidance
1 parent f83cb96 commit a7b7ecd

File tree

9 files changed

+156
-219
lines changed

9 files changed

+156
-219
lines changed

.github/workflows/setup-remote-state.yml

Lines changed: 0 additions & 99 deletions
This file was deleted.

.gitignore

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,4 +501,17 @@ power_platform_deployment_settings
501501

502502
.external_modules/
503503

504-
*.sln
504+
*.sln
505+
506+
# Ignore SSH keys and certificates (security sensitive)
507+
cicd/.ssh/
508+
cicd/.ssh/*
509+
**/.ssh/
510+
*.pem
511+
*.key
512+
*_rsa
513+
*_dsa
514+
*_ecdsa
515+
*_ed25519
516+
*.p12
517+
*.pfx

README.md

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,38 @@ network security.
66

77
## Table of Contents
88

9-
- [Features](#features)
10-
- [Architecture](#architecture)
11-
- [Key Architecture Components](#key-architecture-components)
12-
- [Account & License Requirements](#account--license-requirements)
13-
- [User Configuration](#user-configuration)
14-
- [Getting Started](#getting-started)
15-
- [GitHub Codespaces](#github-codespaces)
16-
- [VS Code Dev Containers](#vs-code-dev-containers)
17-
- [Local Environment](#local-environment)
18-
- [Deploying](#deploying)
19-
- [Using the Bot](#using-the-bot)
20-
- [Clean Up](#clean-up)
21-
- [Testing](#testing)
22-
- [Copilot Studio Agent Test](#copilot-studio-agent-test)
23-
- [AI Search Test (Optional)](#ai-search-test-optional)
24-
- [Advanced Scenarios](#advanced-scenarios)
25-
- [GitHub Self-Hosted Runners](#github-self-hosted-runners)
26-
- [Bring Your Own Networking](#bring-your-own-networking)
27-
- [Custom Resource Group](#custom-resource-group)
28-
- [Additional Considerations](#additional-considerations)
29-
- [Security Considerations](#security-considerations)
30-
- [Production Readiness](#production-readiness)
31-
- [Resources](#resources)
32-
- [Data Collection](#data-collection)
33-
- [Responsible AI](#responsible-ai)
34-
- [Getting Help](#getting-help)
9+
- [Copilot Studio with Azure AI Search](#copilot-studio-with-azure-ai-search)
10+
- [Table of Contents](#table-of-contents)
11+
- [Features](#features)
12+
- [Architecture](#architecture)
13+
- [Key Architecture Components](#key-architecture-components)
14+
- [Account \& License Requirements](#account--license-requirements)
15+
- [User Configuration](#user-configuration)
16+
- [Getting Started](#getting-started)
17+
- [GitHub Codespaces](#github-codespaces)
18+
- [VS Code Dev Containers](#vs-code-dev-containers)
19+
- [Local Environment](#local-environment)
20+
- [Deploying](#deploying)
21+
- [Using the Bot](#using-the-bot)
22+
- [Clean Up](#clean-up)
23+
- [Testing](#testing)
24+
- [Copilot Studio Agent Test](#copilot-studio-agent-test)
25+
- [Running Tests After Local Deployment Execution](#running-tests-after-local-deployment-execution)
26+
- [Running Tests with Manual Environment Variable Configuration](#running-tests-with-manual-environment-variable-configuration)
27+
- [AI Search Test (Optional)](#ai-search-test-optional)
28+
- [Prerequisites for AI Search Tests](#prerequisites-for-ai-search-tests)
29+
- [Running AI Search Tests Locally](#running-ai-search-tests-locally)
30+
- [Advanced Scenarios](#advanced-scenarios)
31+
- [GitHub Self-Hosted Runners](#github-self-hosted-runners)
32+
- [Bring Your Own Networking](#bring-your-own-networking)
33+
- [Custom Resource Group](#custom-resource-group)
34+
- [Additional Considerations](#additional-considerations)
35+
- [Security Considerations](#security-considerations)
36+
- [Production Readiness](#production-readiness)
37+
- [Resources](#resources)
38+
- [Data Collection](#data-collection)
39+
- [Responsible AI](#responsible-ai)
40+
- [Getting Help](#getting-help)
3541

3642
## Features
3743

@@ -161,6 +167,7 @@ A related option is VS Code Dev Containers, which will open the project in your
161167
```
162168
163169
Note that this command will initialize a git repository, so you do not need to clone this repository.
170+
This will also create a new folder with the environment name you entered though the cmd steps in the `.azure` folder. It will also set it as the default environment for any calls to `azd` going forward.
164171
165172
### Deploying
166173
@@ -181,14 +188,6 @@ The steps below will provision Azure and Power Platform resources and will deplo
181188
182189
*Note: the `pac auth create` command may return a warning about being unable to connect to a Dataverse organization. This is expected, and will not impact the deployment.*
183190
184-
1. Create a new azd environment:
185-
186-
```shell
187-
azd env new
188-
```
189-
190-
This will create a new folder in the `.azure` folder, and set it as the active environment for any calls to `azd` going forward.
191-
192191
1. Set you internative testing user.
193192
194193
```shell
@@ -197,7 +196,7 @@ The steps below will provision Azure and Power Platform resources and will deplo
197196
198197
Set this value to the Azure Entra ID object ID of the primary administrator or developer who will manage and modify the deployed solution resources in the future. This user will be granted administrative access to the Power Platform resources (such as bot ownership and environment management) and will have visibility into the Azure resources provisioned by this deployment. Replace `entraid_user_object_id` with the actual object ID of the intended admin or developer.
199198
200-
1. Deploy your infrastructure
199+
3. Deploy your infrastructure
201200
202201
```shell
203202
azd up

azd-hooks/scripts/hooks/preprovision/run_gitleaks.ps1

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ function Run-Gitleaks {
3535

3636
$SourcePath = (Get-Location)
3737

38-
# Get current git branch
38+
# Get current git branch and check if repository has commits
3939
$currentBranch = $null
40+
$hasCommits = $false
41+
4042
try {
4143
Write-Host "Getting current git branch..."
4244
$currentBranch = git branch --show-current
@@ -45,6 +47,19 @@ function Run-Gitleaks {
4547
$currentBranch = "unknown"
4648
} else {
4749
Write-Host "Current git branch: $currentBranch"
50+
51+
# Check if the repository has any commits
52+
try {
53+
git rev-parse HEAD 2>$null | Out-Null
54+
if ($LASTEXITCODE -eq 0) {
55+
$hasCommits = $true
56+
Write-Host "Repository has commits, will use branch reference in log options."
57+
} else {
58+
Write-Host "Repository has no commits yet, will skip branch reference in log options."
59+
}
60+
} catch {
61+
Write-Host "Cannot determine commit history, will skip branch reference in log options."
62+
}
4863
}
4964
} catch {
5065
Write-Warning "Error getting git branch: $_"
@@ -61,8 +76,8 @@ function Run-Gitleaks {
6176
"--log-level", "$LogLevel"
6277
)
6378

64-
# Only add log-opts if we have a valid branch name.
65-
if ($currentBranch -ne "unknown") {
79+
# Only add log-opts if we have a valid branch name and the repository has commits.
80+
if ($currentBranch -ne "unknown" -and $hasCommits) {
6681
$cmdOptions += "--log-opts"
6782
$cmdOptions += "$currentBranch"
6883
}

azure.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ hooks:
4848
continueOnError: false
4949
interactive: false
5050
run: azd-hooks/scripts/hooks/postpackage/postpackage.ps1
51-
pipeline:
52-
variables:
53-
- RESOURCE_SHARE_USER
51+
pipeline:
52+
variables:
53+
- RESOURCE_SHARE_USER
54+
- ACTIONS_RUNNER_NAME

cicd/README.md

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,15 @@ This configuration creates:
3232

3333
```json
3434
{
35-
"subscription_id": "your-subscription-id",
36-
"location": "East US",
37-
"github_token": "your-github-token",
38-
"github_owner": "Azure-Samples",
39-
"github_repository": "Copilot-Studio-with-Azure-AI-Search"
40-
}
35+
"subscription_id": "YOUR_SUBSCRIPTION_ID",
36+
"location": "West US",
37+
"github_runner_config": {
38+
"repo_owner": "YOUR_REPO_OWNER",
39+
"repo_name": "YOUR_REPO_NAME",
40+
},
41+
"github_runner_registration_token": "YOUR_GITHUB_RUNNER_TOKEN_HERE"
42+
43+
}
4144
```
4245

4346
3. Initialize and apply:
@@ -50,21 +53,34 @@ This configuration creates:
5053

5154
## Backend Configuration
5255

53-
After deployment, use the output values to configure your Terraform backend in other projects:
56+
After deployment, use the output to set the remote state values for your template.
5457

5558
```hcl
56-
terraform {
57-
backend "azurerm" {
58-
storage_account_name = "sttfstate<random>"
59-
container_name = "tfstate"
60-
key = "terraform.tfstate"
61-
resource_group_name = "rg-tfstate-<random>"
62-
subscription_id = "your-subscription-id"
63-
use_azuread_auth = true
64-
}
59+
backend_config = {
60+
"container_name" = "CONTAINER_NAME"
61+
"resource_group_name" = "RESOURCE_GROUP_NAME"
62+
"storage_account_name" = "STORAGE_ACCOUNT_NAME"
63+
"subscription_id" = "SUBSCRIPTION_ID"
6564
}
6665
```
6766

67+
```shell
68+
# Set the remote state variables
69+
azd env set RS_STORAGE_ACCOUNT 'STORAGE_ACCOUNT_NAME'
70+
azd env set RS_CONTAINER_NAME 'CONTAINER_NAME'
71+
azd env set RS_RESOURCE_GROUP 'RESOURCE_GROUP_NAME'
72+
73+
# Direct jobs to the new runner by setting a repo variable used by your workflows for `runs-on` selection
74+
azd env set ACTIONS_RUNNER_NAME ['self-hosted']
75+
76+
# Update the template to use remote backend
77+
azd hooks run prepackage
78+
```
79+
80+
- `ACTIONS_RUNNER_NAME`: set to `['self-hosted']` (JSON array syntax) to target any self-hosted runner
81+
82+
Note: The runner VM registers with labels like `self-hosted,vm,<resource-group>,<location>,<unique-id>`. You can narrow job placement further by including those additional labels in your `runs-on` matrix if desired.
83+
6884
## Security Features
6985

7086
- Private storage account (no public access)
@@ -81,16 +97,5 @@ This configuration automatically sets up GitHub repository variables for CI/CD p
8197
- `RS_RESOURCE_GROUP`: Name of the resource group containing the storage account
8298
- `RS_CONTAINER_NAME`: Name of the storage container for Terraform state
8399

84-
These variables can be used in GitHub Actions workflows to configure Terraform backend settings.
85-
86-
## Environment Variables Alternative
100+
These variables will be used in GitHub Actions workflows to configure Terraform backend settings.
87101

88-
Instead of using `terraform.tfvars.json`, you can set environment variables:
89-
90-
```bash
91-
export TF_VAR_subscription_id="your-subscription-id"
92-
export TF_VAR_location="East US"
93-
export TF_VAR_github_token="your-github-token"
94-
export TF_VAR_github_owner="Azure-Samples"
95-
export TF_VAR_github_repository="Copilot-Studio-with-Azure-AI-Search"
96-
```

cicd/terraform.tfvars.json.example

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
{
22
"subscription_id": "00000000-0000-0000-0000-000000000000",
3-
"location": "East US",
4-
"github_owner": "Azure-Samples",
5-
"github_repository": "Copilot-Studio-with-Azure-AI-Search"
3+
"location": "West US",
4+
"github_runner_config": {
5+
"repo_owner": "YOUR_REPO_OWNER",
6+
"repo_name": "YOUR_REPO_NAME",
7+
"runner_type": "vm",
8+
"runner_name": "azure-runner",
9+
"runner_group": "default",
10+
"vm_size": "Standard_D2s_v3",
11+
"vm_os_type": "linux"
12+
},
13+
"github_runner_registration_token": "YOUR_GITHUB_RUNNER_TOKEN_HERE"
614
}

0 commit comments

Comments
 (0)