Skip to content

Latest commit

 

History

History
67 lines (48 loc) · 2.34 KB

File metadata and controls

67 lines (48 loc) · 2.34 KB

SmartBearCoin Payments - Provider Azure Function

A .NET 7 based Azure Function implementation of the SmartBearCoin Payee API.

Coding & Deployment - Provider

Here we implement the API (as per design) by manually creating an Azure Function using .NET 6.0. To speed up the creation and to ensure we conform with the schemas, we'll use SwaggerHub code generation capabilities.

Provider Code

  1. In SwaggerHub export a server stub from the OpenAPI definition (Export > Server Stub > aspnetcore)
  2. Extract the models into the Models > OpenAPI folder of the provider_azure_function solution
  3. Ensure all paths defined in the OpenAPI definition are implemented by an Azure Function controller
  4. Build out the appropriate validation services as required
  5. Ensure all required infrastructure is contained in the Azure Resource Manager template (azuredeploy.json)
  6. Build and commit the project

Provider Flow

  1. Kick off the Provider-API-AzureFunction-CI GitHub action which covers the following:
    • checks out and builds
    • tests using ReadyAPI project created above
    • deploys infra to azure
    • adds provider contract to PactFlow leveraging the can-i-deploy check

If you want to run and edit the provider locally, then take note of the following:

Prerequisites

  • VSCode, Visual Studio or other IDE capable of running .NET 7 projects
  • .NET 7
  • Azure Functions Core Tools (>= v4.0.5571)
  • ngrok

The project was created using VSCode with the following extensions installed:

Ensure that your development certs are trusted (required for debugging)

dotnet dev-certs  https --trust

Running locally

Clone the repo and ensure the project builds

dotnet build

Setup your local.settings.json file. Here is a sample settings configuration:

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"
  },
  "Host": {
    "CORS": "*"
  }
}