Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

API for tkd schools

License

NotificationsYou must be signed in to change notification settings

nicolassnider/TKD_Hub_API

Repository files navigation

This guide covers the complete deployment of the TKD Hub application to Azure, including the .NET Azure Functions API, React SPA, and all supporting infrastructure.

📋 Prerequisites

Required Tools

Azure Resources Needed

  • Azure subscription with appropriate permissions
  • Resource Group (or permissions to create one)

🚀 Quick Start Deployment

Option 1: PowerShell Script (Recommended)

  1. Clone and prepare the repository:

    git clone<your-repo-url>cd TKD_Hub_API
  2. Login to Azure:

    Connect-AzAccount
  3. Run deployment script:

    .\Deploy-TKDHub-Complete.ps1-ResourceGroupName"tkdhub-rg"-AppName"tkdhub"-Location"East US"
  4. Follow the prompts and note the generated SQL password

Option 2: Manual Bicep Deployment

  1. Deploy infrastructure:

    az group create --name"tkdhub-rg" --location"East US"az deployment group create \  --resource-group"tkdhub-rg" \  --template-file"./infra/main.bicep" \  --parameters \    appName="tkdhub" \    location="East US" \    sqlAdminLogin="tkdhubadmin" \    sqlAdminPassword="YourSecurePassword123!"
  2. Deploy Function App:

    cd src/TKDHubAPI.Functionsdotnet publish --configuration Release --output ./publishfunc azure functionapp publish tkdhub-func --csharp
  3. Deploy Static Web App:

    cd frontend/spanpm installnpm run build# Use Static Web Apps CLI or the deployment token from Azureswa deploy ./dist --deployment-token$DEPLOYMENT_TOKEN

🔧 CI/CD Setup

GitHub Actions Setup

  1. Create GitHub repository secrets:

    AZURE_CREDENTIALS              # Service principal credentials (JSON)AZURE_SUBSCRIPTION_ID          # Your Azure subscription IDAZURE_RG_NAME                 # Resource group nameAPP_NAME                      # Application nameAZURE_LOCATION                # Azure region (e.g., "East US")SQL_ADMIN_LOGIN              # SQL Server admin usernameSQL_ADMIN_PASSWORD           # SQL Server admin passwordAZURE_STATIC_WEB_APPS_API_TOKEN # Static Web App deployment token
  2. Create Azure Service Principal:

    az ad sp create-for-rbac --name"tkdhub-github" \  --role contributor \  --scopes /subscriptions/{subscription-id} \  --sdk-auth
  3. Push code to main/master branch to trigger deployment

Azure DevOps Setup

  1. Create Variable Group "TKDHub-Variables":

    azureServiceConnection         # Service connection nameresourceGroupName             # Resource group nameappName                      # Application namelocation                     # Azure regionsqlAdminLogin               # SQL Server admin usernamesqlAdminPassword            # SQL Server admin password (secure)staticWebAppToken           # Static Web App deployment token (secure)
  2. Create Azure Service Connection in Azure DevOps

  3. Import theazure-pipelines.yml file

🏗️ Infrastructure Overview

Deployed Resources

Resource TypeName PatternPurpose
Function App{appName}-func.NET 8 Isolated API
Static Web App{appName}-swaReact SPA hosting
Storage Account{appName}storageFunction App storage
Key Vault{appName}-kvSecrets management
SQL Server{appName}-sqlDatabase server
SQL DatabaseTKDHubDbApplication database
Application Insights{appName}-aiMonitoring & telemetry

Security Features

  • Key Vault Integration: All secrets stored in Azure Key Vault
  • Managed Identity: Function App uses System Assigned Managed Identity
  • HTTPS Only: All services enforce HTTPS
  • CORS Configuration: Proper CORS setup between SPA and API
  • SQL Security: Azure SQL with firewall rules

🔐 Configuration

Required Secrets in Key Vault

Secret NameDescription
ConnectionStrings--DefaultConnectionSQL Server connection string
APPLICATIONINSIGHTS-CONNECTION-STRINGApplication Insights connection string

Environment Variables

Function App automatically configured with:

  • Key Vault references for sensitive settings
  • Application Insights integration
  • Proper runtime configuration

🧪 Testing Deployment

Function App Health Check

curl https://{appName}-func.azurewebsites.net/api/health

Static Web App Access

curl https://{appName}-swa.azurestaticapps.net

Database Connection Test

Use Azure Data Studio or SQL Server Management Studio to connect:

  • Server:{appName}-sql.database.windows.net
  • Database:TKDHubDb
  • Authentication: SQL Server Authentication

🔄 Database Migrations

Using Entity Framework Core

  1. Install EF Core tools:

    dotnet tool install --global dotnet-ef
  2. Update connection string inappsettings.json or use Azure connection string

  3. Run migrations:

    cd src/TKDHubAPI.Infrastructuredotnet ef database update --startup-project ../TKDHubAPI.WebAPI

Using SQL Scripts

Execute scripts from thesql.data/ folder in order:

  1. Core schema setup
  2. Sample data (optional)
  3. Permissions and security

🚨 Troubleshooting

Common Issues

  1. Function App won't start:

    • Check Application Insights connection string
    • Verify Key Vault access permissions
    • Check function app logs in Azure portal
  2. Database connection failures:

    • Verify firewall rules allow Azure services
    • Check connection string format
    • Ensure SQL authentication is enabled
  3. Static Web App routing issues:

    • Verifystaticwebapp.config.json is in thepublic folder
    • Check API routes configuration
    • Ensure proper CORS settings
  4. Deployment failures:

    • Check Azure subscription limits/quotas
    • Verify resource naming conventions
    • Review deployment logs

Monitoring

  • Application Insights: Monitor performance and errors
  • Azure Monitor: Resource health and metrics
  • Function App Logs: Real-time logging via Azure portal or CLI

📚 Additional Resources

💰 Cost Estimation

Monthly Costs (Estimated)

ResourceSKUEstimated Cost
Function AppFlex Consumption$0-10
Static Web AppFree$0
SQL DatabaseBasic (5 DTU)$5
Storage AccountStandard LRS$1-2
Key VaultStandard$1
Application InsightsPay-as-you-go$1-5
Total$8-23/month

Costs may vary based on usage patterns and region selection.

🔒 Security Best Practices

  1. Regular Updates: Keep all packages and dependencies updated
  2. Access Reviews: Regularly review Key Vault access policies
  3. Monitoring: Set up alerts for unusual activity
  4. Backup: Enable point-in-time restore for SQL Database
  5. SSL/TLS: Ensure all communications use HTTPS/TLS 1.2+
  6. Authentication: Implement proper authentication for API endpoints
  7. Secrets Rotation: Regularly rotate passwords and keys

About

API for tkd schools

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp