microsoft / microsoft/GitHub-Copilot-for-Azure

azure-prepare: Function file naming and README/test updates for new functions

Open
#1,000 1 comment 1 reaction 2 assignees Claimed by @paulyuk View on GitHub
enhancement skills
Dominant language
Python
Stars
250
Forks
204
Avg merge
1d 12h
Merged PRs (30d)
67

Description

## Problem

When creating a new Azure Function, the default experience has several UX issues:

### Issue 1: Generic file naming

**Current behavior:**
- User asks to create a function with route `/api/random`
- Agent creates `src/functions/httpTrigger.js`

**Expected behavior:**
- File should be named after the route/function: `src/functions/random.js` or `src/functions/httpRandom.js`
- Generic `httpTrigger` doesn't convey what the function does

### Issue 2: README not updated for new function

**Current behavior:**
- Template README only documents the original template functions
- No mention of the new function that was just created
- User doesn't know how to run/test their new function

**Expected behavior:**
- README should be updated to include:
- New function name and route
- Example curl command to test it
- Any specific configuration needed

### Issue 3: Test files not updated

**Current behavior:**
- Test files (if any) only test template's original functions, which can be unit tests or user test files like test.http or testdata.json used by curl
- No tests scaffolded for the new function

**Expected behavior:**
- revised test files that include new function api or routes asked for by the user

## Suggested Updates to azure-prepare skill

### 1. File naming convention

In `generate.md` or function generation logic:
```markdown
## Function File Naming

Name function files after their route/purpose:
- Route `/api/random` → `src/functions/random.js`
- Route `/api/users` → `src/functions/users.js`
- Route `/api/health` → `src/functions/health.js`

Do NOT use generic names like `httpTrigger.js` unless it's the only function.
```

### 2. README update requirement

Add to generation workflow:
```markdown
## Post-Generation Updates

After creating a new function, update README.md:
1. Add function to "Available Endpoints" table
2. Add curl example for testing
3. Document any required environment variables
```

### 3. Test scaffolding

```markdown
## Test Updates

When creating a new function:
1. If test file exists, add test case for new function
2. If no tests, add comment in README: "TODO: Add tests for {function_name}"
```

## Impact

- Better developer experience
- Self-documenting projects
- Easier onboarding for new team members
- Reduced confusion about what functions exist and how to test them

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.