This repository contains an Azure Functions REST API designed to interact with a SQL database. The API serves as a data provider for a dashboard, enabling users to manipulate and visualize various business KPIs. Additionally, the system supports the creation of VR visualizations from these KPIs.
- SQL Database Integration: Securely fetch, update, and delete KPI data.
- RESTful Endpoints: A set of endpoints for managing and retrieving business KPIs.
- Dashboard Support: Provides data endpoints tailored for dashboard visualizations.
- VR Visualizations: Exposes data in formats suitable for VR visualization tools.
- Azure Account: Ensure you have an active Azure subscription.
- SQL Database: A pre-configured SQL database with necessary tables and data.
- Tools:
- Azure Functions Core Tools for local development.
- Azure CLI for deployment.
- .NET SDK for Azure Functions development.
-
Setup a Azure MS SQL Database
- You can use the DB Structure SQL file to set it up correctly.
-
Clone the repository:
git clone https://github.com/yourusername/azure-functions-kpi-api.git cd azure-functions-kpi-api -
Install dependencies:
dotnet restore
-
Configure your local settings:
- Edit
local.settings.json:{ "IsEncrypted": false, "Values": { "AzureWebJobsStorage": "<Your Azure Storage Connection String>", "FUNCTIONS_WORKER_RUNTIME": "dotnet", "SqlConnectionString": "<Your SQL Database Connection String>" } }
- Edit
-
Run the functions locally:
func start
-
Login to Azure CLI:
az login
-
Create an Azure Function App:
az functionapp create --resource-group <ResourceGroupName> --consumption-plan-location <Region> --runtime dotnet --functions-version 4 --name <AppName> --storage-account <StorageAccountName>
-
Deploy the application:
func azure functionapp publish <AppName>
For more details, please refer to the API_Tests.json file.
POST/api/User/Login- Body:
{"Email": "", "Password": ""}
- Body:
POST/api/User/Add- Body:
{"Name": "", "Email": "", "Password": "", "Username": "", "Salt": ""}
- Body:
GET/api/User/GetAllGET/api/User/Get/{id}GET/api/User/GetByEmail (requiresemailquery parameter)DELETE/api/User/Delete/{id}PUT/api/User/UpdateById/{id}- Body:
{"Name": "", "Tel": "", "Photo": ""}
- Body:
GET/api/User/CheckToken
POST/api/departments- Body:
{"name": "", "description": "", "managerId": ""}
- Body:
GET/api/departmentsGET/api/departments/{id}PUT/api/departments/{id}- Body:
{"name": "", "description": "", "managerId": ""}
- Body:
DELETE/api/departments/{id}POST/api/departments/{departmentId}/kpis/{kpiId}DELETE/api/departments/{departmentId}/kpis/{kpiId}
POST/api/kpis- Body:
{"name": "", "description": "", "target": "", "unit": "", "frequency": ""}
- Body:
GET/api/kpisGET/api/kpis/{id}PUT/api/kpis/{id}- Body:
{"Value_1": "", "Value_2": ""}
- Body:
DELETE/api/kpis/{id}
POST/api/roles- Body:
{"name": "", "description": ""}
- Body:
GET/api/rolesGET/api/roles/{id}PUT/api/roles/{id}- Body:
{"name": "", "description": ""}
- Body:
DELETE/api/roles/{id}PUT/api/roles/{roleId}/departments/{departmentId}/permissions- Body:
{"canRead": "", "canWrite": ""}
- Body:
POST/api/Room/Add- Body:
{"Id": "", "JsonData": ""}
- Body:
GET/api/Room/Get/{id}
This project is licensed under the MIT License. See the LICENSE file for details.
Our project is structured based on the Domain-Driven Design (DDD) approach, and the code is organized into the following folders:
- Controllers: Contains the API controllers that handle incoming requests and responses.
- Services: Contains the business logic and service classes that interact with the database.
- Models: Contains the data models and DTOs (Data Transfer Objects) used in the application.