Skip to content

Refactor: HttpClient usage; update deployment docs - #6

Merged
dariemcarlosdev merged 1 commit into
masterfrom
development
Jul 25, 2026
Merged

Refactor: HttpClient usage; update deployment docs#6
dariemcarlosdev merged 1 commit into
masterfrom
development

Conversation

@dariemcarlosdev

@dariemcarlosdev dariemcarlosdev commented Jul 25, 2026

Copy link
Copy Markdown
Collaborator

Refactor: HttpClient usage; update deployment docs

  • Use AddHttpClient for all service registrations to avoid shared HttpClient timeout issues
  • Add Microsoft.Extensions.Http package and centralize version
  • Clarify in docs that env vars are set on Azure Function App, not Static Web App
  • Cross-reference n8n workflow setup in application settings
  • Improve deployment checklist formatting and backend steps

Summary by CodeRabbit

  • Bug Fixes

    • Improved HTTP client handling for appointment, email, chatbot, and resume services to prevent request failures caused by shared client configuration.
  • Documentation

    • Clarified that runtime settings and secrets belong on the Azure Function App.
    • Updated deployment checklists and environment-variable guidance, including the production n8n webhook reference.
    • Added links to related deployment documentation and refreshed update timestamps.

- Use AddHttpClient<T> for all service registrations to avoid shared HttpClient timeout issues
- Add Microsoft.Extensions.Http package and centralize version
- Clarify in docs that env vars are set on Azure Function App, not Static Web App
- Cross-reference n8n workflow setup in application settings
- Improve deployment checklist formatting and backend steps
Copilot AI review requested due to automatic review settings July 25, 2026 21:17
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Changes

Typed HTTP client wiring

Layer / File(s) Summary
Typed HTTP client registration
CloudZen.csproj, Directory.Packages.props, Program.cs
Adds Microsoft.Extensions.Http version 8.0.1 and registers per-service typed HttpClient instances for appointment, resume, email, and chatbot services.

Azure deployment documentation

Layer / File(s) Summary
Azure deployment guidance
docs/02-deployment/*
Updates Function App environment-variable guidance, adds the n8n webhook documentation reference, refreshes deployment checklist status, and records synchronization metadata.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Program
  participant AppointmentService
  participant DownstreamAPI
  Program->>AppointmentService: Register typed HttpClient with BaseAddress
  AppointmentService->>DownstreamAPI: Send service-specific HTTP request
Loading

Suggested reviewers: copilot

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly reflects the two main themes: HttpClient refactoring and deployment documentation updates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch development

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@dariemcarlosdev
dariemcarlosdev removed the request for review from Copilot July 25, 2026 21:18
@dariemcarlosdev
dariemcarlosdev merged commit 627dff3 into master Jul 25, 2026
2 of 4 checks passed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/02-deployment/AZURE_FUNCTION_DEPLOYMENT.md`:
- Line 187: Update the N8N_WEBHOOK_URL documentation entry to state that an
unset value causes BookAppointmentFunction.cs to return HTTP 500 instead of HTTP
502. Preserve the existing production URL, activation requirement, database
configuration, and workflow setup guidance.

In `@docs/02-deployment/DEPLOYMENT_CHECKLIST.md`:
- Line 38: Update the deployment checklist item to describe the system-assigned
Managed Identity enabled on the Function App and its Key Vault access, removing
the inaccurate reference to linking it with the Static Web App.

In `@Program.cs`:
- Around line 105-106: Update the typed HTTP client registrations for
AppointmentService, ApiEmailService, ChatbotService, and ResumeService to use
their configured ApiBaseUrl values instead of
builder.HostEnvironment.BaseAddress. Resolve the first three base addresses from
each service’s “{Service}:ApiBaseUrl” configuration entry, and configure
ResumeService with the absolute ResumeUrl.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d5811664-7b25-4dee-a44b-0ed2f668e8bf

📥 Commits

Reviewing files that changed from the base of the PR and between a95ebcb and 738c481.

📒 Files selected for processing (6)
  • CloudZen.csproj
  • Directory.Packages.props
  • Program.cs
  • docs/02-deployment/AZURE_FUNCTION_DEPLOYMENT.md
  • docs/02-deployment/DEPLOYMENT_CHECKLIST.md
  • docs/02-deployment/DEPLOYMENT_GUIDE.md

| `BREVO_SMTP_KEY` | `your-brevo-smtp-key` | Brevo SMTP relay key |
| `BREVO_SMTP_LOGIN` | `your-smtp-login@smtp-brevo.com` | Brevo SMTP login |
| `N8N_WEBHOOK_URL` | `https://cloudzen-n8n.pikapod.net/webhook/appointments` | n8n appointment booking webhook — Production URL only, workflow must be activated (required — 502 if unset). Booking DB (Neon Postgres) is configured inside n8n itself, not an Azure resource. |
| `N8N_WEBHOOK_URL` | `https://cloudzen-n8n.pikapod.net/webhook/appointments` | n8n appointment booking webhook — Production URL only, workflow must be activated (required — 502 if unset). Booking DB (Neon Postgres) is configured inside n8n itself, not an Azure resource. See [../08-N8N/appointment-system-v3.md](../08-N8N/appointment-system-v3.md) for workflow setup. |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Correct the missing-configuration status code.

BookAppointmentFunction.cs returns HTTP 500 when N8N_WEBHOOK_URL is unset, not 502. Update the description to prevent incorrect incident diagnosis.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/02-deployment/AZURE_FUNCTION_DEPLOYMENT.md` at line 187, Update the
N8N_WEBHOOK_URL documentation entry to state that an unset value causes
BookAppointmentFunction.cs to return HTTP 500 instead of HTTP 502. Preserve the
existing production URL, activation requirement, database configuration, and
workflow setup guidance.

- [ ] Set `ANTHROPIC_API_KEY` in Azure Function App settings
- [x] Backend created and deployed (`CloudZen.Api`, Consumption plan) — see [AZURE_FUNCTION_DEPLOYMENT.md](AZURE_FUNCTION_DEPLOYMENT.md) for setup
- [x] `SendEmailFunction.cs` and `ChatFunction.cs` deployed
- [x] Managed Identity enabled, linked to Static Web App

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Correct the Managed Identity relationship.

The deployment guide documents a system-assigned identity on the Function App with Key Vault access; it does not establish a Managed Identity link to the Static Web App. Reword this item to reflect the actual Function App/Key Vault configuration.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/02-deployment/DEPLOYMENT_CHECKLIST.md` at line 38, Update the deployment
checklist item to describe the system-assigned Managed Identity enabled on the
Function App and its Key Vault access, removing the inaccurate reference to
linking it with the Static Web App.

Comment thread Program.cs
Comment on lines +105 to +106
builder.Services.AddHttpClient<IAppointmentService, AppointmentService>(client =>
client.BaseAddress = new Uri(builder.HostEnvironment.BaseAddress));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

rg -n -C 6 \
  'class (AppointmentService|ResumeService|ApiEmailService|ChatbotService)|ApiBaseUrl|BaseAddress|GetAsync|PostAsync|SendAsync' \
  --glob '*.cs'

Repository: MyTeamForDev/CloudZen

Length of output: 159


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

echo "== tracked .cs Program.cs files =="
git ls-files '*.cs' | rg '/Program\.cs$|Program\.cs$' || true

echo
echo "== all .cs files with service/client/base/url terms =="
rg -n -i -C 4 \
  'AddHttpClient|BaseAddress|ApiBaseUrl|appointment|resume|email|chatbot|GetAsync|PostAsync|SendAsync|HttpClient' \
  --glob '*.cs' . || true

Repository: MyTeamForDev/CloudZen

Length of output: 50378


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Program.cs relevant section =="
sed -n '80,135p' Program.cs | cat -n

echo
echo "== service implementation files =="
for f in \
  Program.cs \
  Features/Contact/Services/ApiEmailService.cs \
  Features/Chat/Services/ChatbotService.cs \
  Features/Profile/Services/ResumeService.cs
do
  if [ -f "$f" ]; then
    echo "--- $f ---"
    git ls-files | rg "(\b|\bAppointments/Services/AppointmentService.cs)\b" | head -20
  fi
done

echo
echo "== Http methods and BaseAddress/ApiBaseUrl usage in tracked .cs files =="
rg -n \
  'AddHttpClient<I(AppointmentService|ResumeService|ApiEmailService|ChatbotService)|IProjectService)|HttpClient|BaseAddress|CreateFromApiBase|Get.*AsJsonAsync|Send.*Async|Post.*AsJsonAsync|ChatUrl|SendEmailUrl|ResumeUrl|ApiBaseUrl' \
  --glob '*.cs' \
  | head -200

Repository: MyTeamForDev/CloudZen

Length of output: 7166


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
import re, pathlib

root=pathlib.Path('.')
terms='|'.join([
    r'builder\.Services\.AddHttpClient<',
    r'\.BaseAddress\s*=',
    r'ApiBaseUrl',
    r'ChatUrl|SendEmailUrl',
    r'Get.*AsJsonAsync|Post.*AsJsonAsync|Send.*Async',
    r'GetByteArrayAsync',
])
regex=re.compile(terms)

for path in root.rglob('*.cs'):
    text=path.read_text(errors='ignore')
    if not regex.search(text):
        continue
    print(f'\n## {path}')
    for i,line in enumerate(text.splitlines(),1):
        if regex.search(line):
            print(f'{i:4}: {line}')

services=[
    'Features/Contact/Services/ApiEmailService.cs',
    'Features/Chat/Services/ChatbotService.cs',
    'Features/Profile/Services/ResumeService.cs',
]
for svc in services:
    p=pathlib.Path(svc)
    print(f'\n## {p} relevant methods')
    lines=p.read_text(errors='ignore').splitlines()
    for start,end in [(1,80),(80,170),(170,230)]:
        text='\n'.join(lines[s-1:e])
        if any(s in text for s in ['PostAsJsonAsync','GetByteArrayAsync','DeleteAsync','string url']):
            print(f'--- lines {start}-{end} ---')
            print(text)
PY

echo
echo "== find AppointmentService files =="
git ls-files | rg 'Appointment(Service|s).*\.cs$|Appointments/Services' || true

Repository: MyTeamForDev/CloudZen

Length of output: 4282


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path
for svc in [
    "Features/Booking/Services/AppointmentService.cs",
    "Features/Contact/Services/ApiEmailService.cs",
    "Features/Chat/Services/ChatbotService.cs",
    "Features/Profile/Services/ResumeService.cs",
]:
    p=Path(svc)
    if not p.exists():
        print(f"MISSING {svc}")
        continue
    text=p.read_text(errors="ignore")
    print(f"\n## {p}")
    start=len(text)
    for meth in ["CreateFromApiBase", "SendAsync", "PostAsJsonAsync", "GetByteArrayAsync"]:
        idx=text.find(meth)
        if idx>=0 and idx<start:
            start=idx
    print(text[start:start+1200])
PY

echo
echo "== deterministic Uri/BaseAddress behavior =="
python3 - <<'PY'
from urllib.parse import urljoin
host='https://app.example/'
local='http://localhost:7257/api'
for path in ['/api', 'api/', '/api/send-email']:
    print(path, 'with host BaseAddress ->', urljoin(host, path))
    print(path, 'with local BaseAddress ->', urljoin(local, path))
PY

echo
echo "== check SendAsJsonAsync extension signature/source availability =="
rg -n "CreateFromApiBase|IAppointmentService|AddHttpClient<IAppointmentService|localUrl|functionsLocalUrl|ApiBaseUrl" Program.cs Features/Booking Features/Contact Features/Chat Features/Profile --glob '*.cs'

Repository: MyTeamForDev/CloudZen

Length of output: 7526


Configure the typed HTTP clients from the local functions URL.

builder.Configuration["{Service}:ApiBaseUrl"] = functionsLocalUrl is set, but the typed clients override BaseAddress to builder.HostEnvironment.BaseAddress. Since AppointmentService sends relative requests and ApiEmailService/ChatbotService compose endpoint paths from ApiBaseUrl, these requests will be routed to the WebAssembly origin in development. Set each typed client’s BaseAddress from its ApiBaseUrl; use the absolute ResumeUrl for ResumeService.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Program.cs` around lines 105 - 106, Update the typed HTTP client
registrations for AppointmentService, ApiEmailService, ChatbotService, and
ResumeService to use their configured ApiBaseUrl values instead of
builder.HostEnvironment.BaseAddress. Resolve the first three base addresses from
each service’s “{Service}:ApiBaseUrl” configuration entry, and configure
ResumeService with the absolute ResumeUrl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant