- Notifications
You must be signed in to change notification settings - Fork0
nicolassnider/TKD_Hub_API
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
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.
- Azure CLI
- Azure Functions Core Tools
- .NET 8.0 SDK
- Node.js 18.x or later
- PowerShell 7+ (for deployment script)
- Git
- Azure subscription with appropriate permissions
- Resource Group (or permissions to create one)
Clone and prepare the repository:
git clone<your-repo-url>cd TKD_Hub_API
Login to Azure:
Connect-AzAccount
Run deployment script:
.\Deploy-TKDHub-Complete.ps1-ResourceGroupName"tkdhub-rg"-AppName"tkdhub"-Location"East US"
Follow the prompts and note the generated SQL password
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!"
Deploy Function App:
cd src/TKDHubAPI.Functionsdotnet publish --configuration Release --output ./publishfunc azure functionapp publish tkdhub-func --csharp
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
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
Create Azure Service Principal:
az ad sp create-for-rbac --name"tkdhub-github" \ --role contributor \ --scopes /subscriptions/{subscription-id} \ --sdk-auth
Push code to main/master branch to trigger deployment
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)
Create Azure Service Connection in Azure DevOps
Import the
azure-pipelines.yml
file
Resource Type | Name Pattern | Purpose |
---|---|---|
Function App | {appName}-func | .NET 8 Isolated API |
Static Web App | {appName}-swa | React SPA hosting |
Storage Account | {appName}storage | Function App storage |
Key Vault | {appName}-kv | Secrets management |
SQL Server | {appName}-sql | Database server |
SQL Database | TKDHubDb | Application database |
Application Insights | {appName}-ai | Monitoring & telemetry |
- 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
Secret Name | Description |
---|---|
ConnectionStrings--DefaultConnection | SQL Server connection string |
APPLICATIONINSIGHTS-CONNECTION-STRING | Application Insights connection string |
Function App automatically configured with:
- Key Vault references for sensitive settings
- Application Insights integration
- Proper runtime configuration
curl https://{appName}-func.azurewebsites.net/api/health
curl https://{appName}-swa.azurestaticapps.net
Use Azure Data Studio or SQL Server Management Studio to connect:
- Server:
{appName}-sql.database.windows.net
- Database:
TKDHubDb
- Authentication: SQL Server Authentication
Install EF Core tools:
dotnet tool install --global dotnet-ef
Update connection string in
appsettings.json
or use Azure connection stringRun migrations:
cd src/TKDHubAPI.Infrastructuredotnet ef database update --startup-project ../TKDHubAPI.WebAPI
Execute scripts from thesql.data/
folder in order:
- Core schema setup
- Sample data (optional)
- Permissions and security
Function App won't start:
- Check Application Insights connection string
- Verify Key Vault access permissions
- Check function app logs in Azure portal
Database connection failures:
- Verify firewall rules allow Azure services
- Check connection string format
- Ensure SQL authentication is enabled
Static Web App routing issues:
- Verify
staticwebapp.config.json
is in thepublic
folder - Check API routes configuration
- Ensure proper CORS settings
- Verify
Deployment failures:
- Check Azure subscription limits/quotas
- Verify resource naming conventions
- Review deployment logs
- Application Insights: Monitor performance and errors
- Azure Monitor: Resource health and metrics
- Function App Logs: Real-time logging via Azure portal or CLI
- Azure Functions Documentation
- Azure Static Web Apps Documentation
- Azure Bicep Documentation
- Entity Framework Core Documentation
Resource | SKU | Estimated Cost |
---|---|---|
Function App | Flex Consumption | $0-10 |
Static Web App | Free | $0 |
SQL Database | Basic (5 DTU) | $5 |
Storage Account | Standard LRS | $1-2 |
Key Vault | Standard | $1 |
Application Insights | Pay-as-you-go | $1-5 |
Total | $8-23/month |
Costs may vary based on usage patterns and region selection.
- Regular Updates: Keep all packages and dependencies updated
- Access Reviews: Regularly review Key Vault access policies
- Monitoring: Set up alerts for unusual activity
- Backup: Enable point-in-time restore for SQL Database
- SSL/TLS: Ensure all communications use HTTPS/TLS 1.2+
- Authentication: Implement proper authentication for API endpoints
- Secrets Rotation: Regularly rotate passwords and keys
About
API for tkd schools
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.