See TelemetryStash, Database about running integration tests.
The setup of azure resources is done with bicep and az cli.
- Create the resource group
az group create --name {RESOURCE_GROUP_NAME} --location swedencentral
- 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
A SQL database with RepoDb ORM is used. The database is created and updated via Ts.TelemetryDatabase.Sql 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
USE [{DATABASE_NAME}]
CREATE USER [{IDENTITY}] FROM EXTERNAL PROVIDER;
EXEC sp_addrolemember 'db_datareader', [{IDENTITY}];
ALTER ROLE [db_execute_procedure_role] ADD MEMBER [{IDENTITY}]
- 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
- 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
@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.