Skip to content

Latest commit

 

History

History

backend

TelemetryStash, Backend

Testing

See TelemetryStash, Database about running integration tests.

Infrastructure as code

The setup of azure resources is done with bicep and az cli.

Deploy azure resources to a new resource group

  1. Create the resource group
az group create --name {RESOURCE_GROUP_NAME} --location swedencentral
  1. Run the az cli command to deploy resources
az deployment group create --resource-group {RESOURCE_GROUP_NAME} --parameters ts.{ENV}.bicepparam

💡 Note. Publish Ts.Functions and run again if deployment fails

Deploy SQL database

A SQL database with RepoDb ORM is used. The database is created and updated via Ts.TelemetryDatabase.Sql project.

Publish database project

Publish the database project via Visual Studio Schema Compare or CLI.

dotnet tool install -g microsoft.sqlpackage
./SqlPackage /Action:Publish /SourceFile:bin/Ts.TelemetryDatabase.Sql.dacpac /TargetServerName:{SQL_SERVER} /TargetDatabaseName:Ts.TelemetryDatabase.Sql

Allow functions to access database

USE [{DATABASE_NAME}]
CREATE USER [{IDENTITY}] FROM EXTERNAL PROVIDER;
EXEC sp_addrolemember 'db_datareader', [{IDENTITY}];
ALTER ROLE [db_execute_procedure_role] ADD MEMBER [{IDENTITY}]

Create certificates

  • Add to Key Vault
    • Secret: Client--CertificatePassword
    • Secret: Certificate--RootCaPassword
  • Generate a root certificate
    • /src/misc/generate-root-cert.ps1
  • Optional: Generate a client certificates to Key Vault
  • Optional: Generate client certificates to Key Vault
    • /src/misc/generate-client-cert.ps1

Configure IoT Hub

  • Add root Telemetry Stash Root CA PEM certificate to IoT Hub
    • Enable: Set certificate status to verified on upload
  • Create device
    • Device ID: Must match the client certificate CN, eg: Client-Dev1
    • Authentication type: X.509 CA signed

Ways of working

Pull requests

 @coderabbitai full review: Conducts a full review from scratch, covering all files again.
 @coderabbitai summary: Regenerates the summary of the PR.
 @coderabbitai configuration: Displays the current CodeRabbit configuration for the repository.