Instructions on setting up and running the v3 APIs locally.
Before you begin, ensure you have met the following requirements:
1. You have installed .NET 7
OS | Installers |
---|---|
Linux | Package manager instructions |
macOS | Arm64 I x64 |
Widnows | x64 I x86 |
All | dotnet-install scripts |
2. You have installed Azure Functions Core Tools v4.x
Azure Functions Core Tools lets you develop and test your functions on your local computer from the command prompt or terminal. Your local functions can connect to live Azure services, and you can debug your functions on your local computer using the full Functions runtime.
⚠️ Note
Don't mix local development with portal development in the same function app. When you create and publish functions from a local project, you won't be able to maintain or modify project code in the portal.
3. Local storage emulator Azurite
During local development, you can use the local Azurite emulator when testing functions with Azure Storage bindings, without having to connect to remote storage services. Azurite integrates with Visual Studio Code and Visual Studio, and you can also run it from the command prompt using npm. For more information, see Use the Azurite emulator for local Azure Storage development.
The following setting in the Values collection of the local.settings.json file tells the local Functions host to use Azurite for the default AzureWebJobsStorage connection:
"AzureWebJobsStorage": "UseDevelopmentStorage=true"
Follow these steps to get your development environment set up and running locally
Clone the repository using SSH.
git clone [email protected]:prepaidtech/dash-api.git
Set up personal SSH keys on Windows | Bitbucket Cloud
Clone the repository using HTTPS.
git clone https://<your-profile-name>@bitbucket.org/prepaidtech/dash-api.git
cd <project-name>
Run below command to restore all the necessary dependencies and packages for the project.
dotnet restore
A Functions project directory contains the following files and folders, regardless of language:
local.settings.json
Settings used by Core Tools when running locally, including app settings. To learn more, see local settings.
{
"IsEncrypted": false,
"Values" : {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
"MyConnection": "<connection-string-to-your-databse>",
"MyOptions:Option1": "value",
"MyOptions:Option2": "value"
},
"ConnectionStrings": {
"DefaultConnection": "UseDevelopmentStorage=true"
}
}
host.json
The global configuration file host.json includes settings that affect all functions deployed under the same function app. To learn more, see the host.json reference.
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
}
}
We have 5 .NET Azure Function Apps
in our solution.
Dash.Api.Audits.Functions
Dash.Api.Cards.Functions
Dash.Api.Payments.Functions
Dash.Api.Users.Functions
Dash.Api.Webhooks.Functions
Navigate to the project directory you want it to be running.
Using the following command to Start the Azure Functions runtime host.
func start
⚠️ Note
Make sure you have host.json and local.settings.json files and those are configured properly before running the Function App.
If the Function App is running correctly, you can see similar screen on the console.
Test with Postman
Postman is a standalone software testing API platform to build, test, design, modify, and document APIs.
You can see OpenAPI definitions here for Function Apps.
dash-api\Dash.Terraform\modules
Once you have Function App
up and running, you can import the OpenAPI definitions into Postman to test them out.
e.g. Dash Cards API
dash-api\Dash.Terraform\modules\cards-service\open-api-cards.yaml
⚠️ Note
Make sure you are using Postman Desktop Agent
To contribute to <Project Name>
, follow these steps:
- Fork this repository.
- Create a branch:
git checkout -b <branch_name>
. - Make your changes and commit them:
git commit -m '<commit_message>'
- Push to the original branch:
git push origin <project>/<location>
- Create the pull request.
Alternatively see the Bitbucket documentation on creating a pull request.