-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge v3 Features to main branch (#1144)
* Add target branche to CI actions * Add PostgreSQL database to deployment (#1112) * Add PostgreSQL database to deployment * Add ARM lint task to v3-dev branch * Add github actions to solution file * Feature/add pgsql database connection (#1121) * Add entityframework + PGSql nuget packages * Add PGSql database context + initial database creation * Add Quartz.NET Scheduler to server (#1135) * Ignore migration files to code coverage * Migrate v3-dev to v3/main branch * Add unit of work and generic repository (#1154) * Add unit of work and generic repository * Add infrastructure layer + domain layer * Move Device model property to database (#1155) * Fix #984 - Refactor DeviceModelPropertiesController (#1159) * Rebase from main * Remove start Azurite from the build pipeline * Add database servcie as adependency to iot hub portal #1175 * Fix PostgreSQL arm deployment on V3 (#1183) * Feature: Add PostgreSQL login/password fields to arm ui form #1181 * Fix postgsql arm deployment #1180 * Update temporary arm templates urls for testing * Update arm templates url to target main branch * Set pgsqlAdminPassword parameter as securestring (#1188) Co-authored-by: Hocine Hacherouf <hacherouf.hocine@gmail.com>
- Loading branch information
1 parent
b1d1971
commit 1fc869e
Showing
131 changed files
with
2,687 additions
and
4,622 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/AzureIoTHub.Portal.Infrastructure/AzureIoTHub.Portal.Infrastructure.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Azure.Data.Tables" Version="12.6.1" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.2.7" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.2.0" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Hosting.Server.Abstractions" Version="2.2.0" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.8" /> | ||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="6.0.8" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.8" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.8" /> | ||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.6" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\AzureIoTHubPortal.Domain\AzureIoTHub.Portal.Domain.csproj" /> | ||
|
||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/AzureIoTHub.Portal.Infrastructure/ConfigHandlerFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) CGI France. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace AzureIoTHub.Portal.Infrastructure | ||
{ | ||
using System; | ||
using AzureIoTHub.Portal.Domain; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.Hosting; | ||
|
||
public static class ConfigHandlerFactory | ||
{ | ||
public static ConfigHandler Create(IHostEnvironment env, IConfiguration config) | ||
{ | ||
ArgumentNullException.ThrowIfNull(env, nameof(env)); | ||
ArgumentNullException.ThrowIfNull(config, nameof(config)); | ||
|
||
if (env.IsProduction()) | ||
{ | ||
return new ProductionConfigHandler(config); | ||
} | ||
|
||
return new DevelopmentConfigHandler(config); | ||
} | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
src/AzureIoTHub.Portal.Infrastructure/DevelopmentConfigHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Copyright (c) CGI France. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace AzureIoTHub.Portal.Infrastructure | ||
{ | ||
using Microsoft.Extensions.Configuration; | ||
|
||
internal class DevelopmentConfigHandler : ConfigHandlerBase | ||
{ | ||
private readonly IConfiguration config; | ||
|
||
internal DevelopmentConfigHandler(IConfiguration config) | ||
{ | ||
this.config = config; | ||
} | ||
|
||
public override string PortalName => this.config[PortalNameKey]; | ||
|
||
public override int MetricExporterRefreshIntervalInSeconds => this.config.GetValue(MetricExporterRefreshIntervalKey, 30); | ||
|
||
public override int MetricLoaderRefreshIntervalInMinutes => this.config.GetValue(MetricLoaderRefreshIntervalKey, 10); | ||
|
||
public override string IoTHubConnectionString => this.config[IoTHubConnectionStringKey]; | ||
|
||
public override string DPSConnectionString => this.config[DPSConnectionStringKey]; | ||
|
||
public override string DPSEndpoint => this.config[DPSServiceEndpointKey]; | ||
|
||
public override string DPSScopeID => this.config[DPSIDScopeKey]; | ||
|
||
public override string StorageAccountConnectionString => this.config[StorageAccountConnectionStringKey]; | ||
|
||
public override int StorageAccountDeviceModelImageMaxAge => this.config.GetValue(StorageAccountDeviceModelImageMaxAgeKey, 86400); | ||
|
||
public override bool UseSecurityHeaders => this.config.GetValue(UseSecurityHeadersKey, true); | ||
|
||
public override string OIDCScope => this.config[OIDCScopeKey]; | ||
|
||
public override string OIDCAuthority => this.config[OIDCAuthorityKey]; | ||
|
||
public override string OIDCMetadataUrl => this.config[OIDCMetadataUrlKey]; | ||
|
||
public override string OIDCClientId => this.config[OIDCClientIdKey]; | ||
|
||
public override string OIDCApiClientId => this.config[OIDCApiClientIdKey]; | ||
|
||
public override bool OIDCValidateIssuer => this.config.GetValue(OIDCValidateIssuerKey, true); | ||
|
||
public override bool OIDCValidateAudience => this.config.GetValue(OIDCValidateAudienceKey, true); | ||
|
||
public override bool OIDCValidateLifetime => this.config.GetValue(OIDCValidateLifetimeKey, true); | ||
|
||
public override bool OIDCValidateIssuerSigningKey => this.config.GetValue(OIDCValidateIssuerSigningKeyKey, true); | ||
|
||
public override bool OIDCValidateActor => this.config.GetValue(OIDCValidateActorKey, false); | ||
|
||
public override bool OIDCValidateTokenReplay => this.config.GetValue(OIDCValidateTokenReplayKey, false); | ||
|
||
public override bool IsLoRaEnabled => bool.Parse(this.config[IsLoRaFeatureEnabledKey] ?? "true"); | ||
|
||
public override string LoRaKeyManagementUrl => this.config[LoRaKeyManagementUrlKey]; | ||
|
||
public override string LoRaKeyManagementCode => this.config[LoRaKeyManagementCodeKey]; | ||
|
||
public override string LoRaKeyManagementApiVersion => this.config[LoRaKeyManagementApiVersionKey]; | ||
|
||
public override bool IdeasEnabled => this.config.GetValue(IdeasEnabledKey, false); | ||
public override string IdeasUrl => this.config.GetValue(IdeasUrlKey, string.Empty); | ||
public override string IdeasAuthenticationHeader => this.config.GetValue(IdeasAuthenticationHeaderKey, "Ocp-Apim-Subscription-Key"); | ||
public override string IdeasAuthenticationToken => this.config.GetValue(IdeasAuthenticationTokenKey, string.Empty); | ||
|
||
public override string PostgreSQLConnectionString => this.config[PostgreSQLConnectionStringKey]; | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
src/AzureIoTHub.Portal.Infrastructure/Factories/TableClientFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Copyright (c) CGI France. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace AzureIoTHub.Portal.Infrastructure.Factories | ||
{ | ||
using System; | ||
using Azure; | ||
using Azure.Data.Tables; | ||
using AzureIoTHub.Portal.Domain; | ||
using AzureIoTHub.Portal.Domain.Exceptions; | ||
|
||
public class TableClientFactory : ITableClientFactory | ||
{ | ||
private readonly string connectionString; | ||
|
||
internal const string DeviceCommandTableName = "DeviceCommands"; | ||
internal const string DeviceTemplateTableName = "DeviceTemplates"; | ||
internal const string EdgeDeviceTemplateTableName = "EdgeDeviceTemplates"; | ||
internal const string DeviceTagSettingTableName = "DeviceTagSettings"; | ||
internal const string DeviceTemplatePropertiesTableName = "DeviceTemplateProperties"; | ||
internal const string EdgeModuleCommandsTableName = "EdgeModuleCommands"; | ||
|
||
public TableClientFactory(string connectionString) | ||
{ | ||
this.connectionString = connectionString; | ||
} | ||
|
||
public TableClient GetDeviceCommands() | ||
{ | ||
return CreateClient(DeviceCommandTableName); | ||
} | ||
|
||
public TableClient GetDeviceTemplates() | ||
{ | ||
return CreateClient(DeviceTemplateTableName); | ||
} | ||
|
||
public TableClient GetEdgeDeviceTemplates() | ||
{ | ||
return CreateClient(EdgeDeviceTemplateTableName); | ||
} | ||
|
||
public TableClient GetDeviceTagSettings() | ||
{ | ||
return CreateClient(DeviceTagSettingTableName); | ||
} | ||
|
||
private TableClient CreateClient(string tableName) | ||
{ | ||
var tableClient = new TableClient(this.connectionString, tableName); | ||
_ = tableClient.CreateIfNotExists(); | ||
|
||
return tableClient; | ||
} | ||
|
||
public TableClient GetDeviceTemplateProperties() | ||
{ | ||
return CreateClient(DeviceTemplatePropertiesTableName); | ||
} | ||
|
||
public TableClient GetTemplatesHealthCheck() | ||
{ | ||
return CreateClient("tableHealthCheck"); | ||
} | ||
|
||
public TableClient GetEdgeModuleCommands() | ||
{ | ||
return CreateClient(EdgeModuleCommandsTableName); | ||
} | ||
} | ||
} |
Oops, something went wrong.