Skip to content

Commit dd7b807

Browse files
committed
document PowerShell requirements for Azure Functions scripts
Add PowerShell installation instructions and version requirements: - Minimum: PowerShell 5.1 (Windows built-in) - Recommended: PowerShell 7+ (cross-platform) - Always prefer pwsh over powershell.exe when available Add runtime version checks to all three scripts with helpful error messages. 🤖 Co-Authored-By: Claude Code <noreply@anthropic.com>
1 parent f932517 commit dd7b807

6 files changed

Lines changed: 134 additions & 1 deletion

File tree

.claude/skills/azure-functions/README.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,59 @@ When invoked without arguments (`/azure-functions`), the skill guides you throug
8484

8585
### Prerequisites
8686

87-
Users provide their own:
87+
**PowerShell**:
88+
- **Recommended**: PowerShell 7+ (`pwsh`) - cross-platform, modern features
89+
- **Minimum**: PowerShell 5.1 (`powershell.exe` on Windows only)
90+
- [Installation instructions](#installing-powershell)
91+
92+
**Azure resources** (users provide their own):
8893
- **App name** (`-AppName`): The Azure Function App to deploy to
8994
- **Resource group** (`-ResourceGroup`): The Azure resource group containing the app
9095
- **Sample app path** (`-SampleAppPath`): Local path to an Azure Functions app that references the `Datadog.AzureFunctions` NuGet package
9196

9297
The sample app must have a `nuget.config` (in the app directory or a parent directory) that defines a local NuGet feed. The `-CopyTo` parameter of `Build-AzureFunctionsNuget.ps1` should point to the same directory as that local feed so `dotnet restore` picks up the freshly built package.
9398

99+
### Installing PowerShell
100+
101+
PowerShell 5.1+ is required to run the Azure Functions automation scripts.
102+
103+
**Windows users**: PowerShell 5.1 is already included with Windows 10/11. You can use the built-in `powershell.exe` or install PowerShell 7+ for the latest features.
104+
105+
**macOS/Linux users**: PowerShell 7+ is required (cross-platform version).
106+
107+
#### PowerShell 7+ (Recommended)
108+
109+
**Windows**:
110+
```powershell
111+
winget install Microsoft.PowerShell
112+
```
113+
114+
**macOS**:
115+
```bash
116+
brew install powershell/tap/powershell
117+
```
118+
119+
**Linux (Ubuntu/Debian)**:
120+
```bash
121+
# Download the Microsoft repository GPG keys
122+
wget -q https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb
123+
124+
# Register the Microsoft repository GPG keys
125+
sudo dpkg -i packages-microsoft-prod.deb
126+
127+
# Update apt and install PowerShell
128+
sudo apt-get update
129+
sudo apt-get install -y powershell
130+
```
131+
132+
**Linux (Other distributions)**: https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell
133+
134+
**Verify installation**:
135+
```bash
136+
pwsh -Version
137+
# Should output: PowerShell 7.x.x or higher
138+
```
139+
94140
## Documentation References
95141

96142
- `docs/development/AzureFunctions.md` - Complete Azure Functions integration guide

.claude/skills/azure-functions/SKILL.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,32 @@ allowed-tools: Bash(az:functionapp:show:*) Bash(az:functionapp:list:*) Bash(az:f
1010

1111
This skill guides you through building, deploying, and testing Azure Functions with Datadog instrumentation.
1212

13+
## Prerequisites
14+
15+
**CRITICAL**: This skill requires PowerShell to run the Azure Functions automation scripts.
16+
17+
**PowerShell version requirements**:
18+
- **Recommended**: PowerShell 7+ (`pwsh`) - cross-platform, modern features
19+
- **Minimum**: PowerShell 5.1 (`powershell.exe` on Windows only)
20+
21+
**Installation**:
22+
- Windows: `winget install Microsoft.PowerShell` (or use built-in PowerShell 5.1)
23+
- macOS: `brew install powershell/tap/powershell`
24+
- Linux: https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-linux
25+
26+
**If the user does not have PowerShell installed**:
27+
1. Check for `pwsh` first: `pwsh -Version`
28+
2. If not found and on Windows, check for PowerShell 5.1: `powershell -NoProfile -Command '$PSVersionTable.PSVersion'`
29+
3. If neither found or version is too old, provide installation instructions from [README.md](README.md#installing-powershell)
30+
4. Do NOT attempt to replicate the script functionality using bash - the scripts use PowerShell-specific cmdlets like `Expand-Archive`
31+
32+
**Always prefer `pwsh` over `powershell.exe`** when both are available (better cross-platform compatibility and modern features).
33+
34+
**Other requirements**:
35+
- Azure CLI (`az`) authenticated
36+
- Azure Functions Core Tools (`func`)
37+
- .NET SDK (matching target framework of sample app)
38+
1339
## Commands
1440

1541
When invoked with an argument, perform the corresponding workflow:

.claude/skills/azure-functions/scripts-reference.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ Quick reference scripts and commands for Azure Functions development workflow.
44

55
## PowerShell Scripts (tracer/tools/)
66

7+
**Prerequisites**: PowerShell 5.1+ is required for all scripts in this section.
8+
- **Recommended**: PowerShell 7+ (`pwsh`) for cross-platform support
9+
- **Minimum**: PowerShell 5.1 (`powershell.exe` on Windows)
10+
- Verify: `pwsh -Version` or `powershell -NoProfile -Command '$PSVersionTable.PSVersion'`
11+
12+
**Note**: These scripts use PowerShell-specific cmdlets (e.g., `Expand-Archive`, `Invoke-RestMethod`) that cannot be easily replicated in bash. Always prefer `pwsh` over `powershell.exe` when both are available.
13+
714
### Deploy-AzureFunction.ps1
815

916
Automates deployment, wait, and HTTP trigger with timestamp capture.

tracer/tools/Build-AzureFunctionsNuget.ps1

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,24 @@ param(
5757
)
5858

5959
$ErrorActionPreference = 'Stop'
60+
61+
# Verify PowerShell version (requires 5.1+ for Expand-Archive and modern cmdlets)
62+
if ($PSVersionTable.PSVersion.Major -lt 5 -or
63+
($PSVersionTable.PSVersion.Major -eq 5 -and $PSVersionTable.PSVersion.Minor -lt 1)) {
64+
Write-Error @"
65+
This script requires PowerShell 5.1 or higher.
66+
Current version: $($PSVersionTable.PSVersion)
67+
68+
Install PowerShell 7+ (recommended for cross-platform support):
69+
- Windows: winget install Microsoft.PowerShell
70+
- macOS: brew install powershell/tap/powershell
71+
- Linux: https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-linux
72+
73+
Or use PowerShell 5.1 (Windows only):
74+
- Included with Windows 10/11 - run with: powershell.exe (not powershell.exe -Version 2)
75+
"@
76+
exit 1
77+
}
6078
$ProgressPreference = 'SilentlyContinue'
6179

6280
# Set dotnet and nuke verbosity based on PowerShell verbose mode

tracer/tools/Deploy-AzureFunction.ps1

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,24 @@ param(
8181
Set-StrictMode -Version Latest
8282
$ErrorActionPreference = 'Stop'
8383

84+
# Verify PowerShell version (requires 5.1+ for modern cmdlets)
85+
if ($PSVersionTable.PSVersion.Major -lt 5 -or
86+
($PSVersionTable.PSVersion.Major -eq 5 -and $PSVersionTable.PSVersion.Minor -lt 1)) {
87+
Write-Error @"
88+
This script requires PowerShell 5.1 or higher.
89+
Current version: $($PSVersionTable.PSVersion)
90+
91+
Install PowerShell 7+ (recommended for cross-platform support):
92+
- Windows: winget install Microsoft.PowerShell
93+
- macOS: brew install powershell/tap/powershell
94+
- Linux: https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-linux
95+
96+
Or use PowerShell 5.1 (Windows only):
97+
- Included with Windows 10/11 - run with: powershell.exe (not powershell.exe -Version 2)
98+
"@
99+
exit 1
100+
}
101+
84102
# Guard: Verify prerequisites
85103
Write-Verbose "Verifying prerequisites..."
86104

tracer/tools/Get-AzureFunctionLogs.ps1

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,24 @@ param(
8484
Set-StrictMode -Version Latest
8585
$ErrorActionPreference = 'Stop'
8686

87+
# Verify PowerShell version (requires 5.1+ for Expand-Archive and modern cmdlets)
88+
if ($PSVersionTable.PSVersion.Major -lt 5 -or
89+
($PSVersionTable.PSVersion.Major -eq 5 -and $PSVersionTable.PSVersion.Minor -lt 1)) {
90+
Write-Error @"
91+
This script requires PowerShell 5.1 or higher.
92+
Current version: $($PSVersionTable.PSVersion)
93+
94+
Install PowerShell 7+ (recommended for cross-platform support):
95+
- Windows: winget install Microsoft.PowerShell
96+
- macOS: brew install powershell/tap/powershell
97+
- Linux: https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-linux
98+
99+
Or use PowerShell 5.1 (Windows only):
100+
- Included with Windows 10/11 - run with: powershell.exe (not powershell.exe -Version 2)
101+
"@
102+
exit 1
103+
}
104+
87105
# Apply -All switch
88106
if ($All) {
89107
$ShowVersion = $true

0 commit comments

Comments
 (0)