public Ingress(CloudBackend cloudBackend, CloudGateway hub, TelemetryStorage telemetryStorage, MasterDataStorage masterDataStorage, SanitizedMessages sanitizedMessages, ApplicationInsights applicationInsights, IInfrastructureEnvironment environment) { Container = cloudBackend.System.AddContainer( name: "Ingress", description: "Receives incoming data from the cloud gateway and saves it into master data and telemetry data storages", technology: "Azure Function"); Infrastructure = new FunctionAppService { Name = "ref-ingress-" + environment.Name }; Uses(hub) .Over <IoTHubSDK>() .InOrderTo("Subscribes to incoming messages"); Uses(sanitizedMessages) .Over <EventHubSDK>() .InOrderTo("Publish sanitized messages"); Uses(telemetryStorage) .Over(telemetryStorage.Infrastructure.TableEndpoint) .InOrderTo("Persist telemetry data"); Uses(masterDataStorage).InOrderTo("Persist master data"); Uses(applicationInsights).InOrderTo("Log metrics"); }
public SanitizedMessages(CloudBackend cloudBackend, EventHubNamespace eventHubNamespace, IInfrastructureEnvironment environment) { Container = cloudBackend.System.AddContainer( name: "Sanitized messages", description: "Contains messages from devices that have been deserialized, sanitized and checked for security properties", technology: "Azure Event Hub"); Infrastructure = new EventHub(eventHubNamespace.Infrastructure) { Name = "sanitized-messages", EnvironmentInvariantName = "sanitized-messages" }; }
public MasterDataStorage(CloudBackend cloudBackend, SqlServer sqlServer, IInfrastructureEnvironment environment) { Container = cloudBackend.System.AddContainer( name: "Master Data Storage", description: "Stores master data", technology: "Azure SQL Database"); Infrastructure = new SqlDatabase(sqlServer.Infrastructure) { Name = "masterdata" + environment.Name }; }
public CloudGateway(CloudBackend cloudBackend, IInfrastructureEnvironment environment) { Container = cloudBackend.System.AddContainer( name: "Cloud Gateway", description: "Receives incoming messages from the device", technology: "Azure IoT Hub"); Infrastructure = new IoTHub { Name = "ref-hub-" + environment.Name, EnvironmentInvariantName = "ref-hub" }; }
public ApplicationInsights(CloudBackend cloudBackend, IInfrastructureEnvironment environment) { Container = cloudBackend.System.AddContainer( name: "Application Insights", description: "Serves as a logging target and monitoring tool", technology: "Azure Application Insights"); Infrastructure = new Structurizr.InfrastructureAsCode.Azure.Model.ApplicationInsights { Name = "ref-ai-" + environment.Name }; }
public SecretStorage(CloudBackend cloudBackend, IInfrastructureEnvironment environment) { Container = cloudBackend.System.AddContainer( "Secret storage", "Stores secrets that other services require to access each other", "Azure Key Vault"); Infrastructure = new KeyVault { Name = "ref-keyvault-" + environment.Name }; }
public UserInterface(CloudBackend cloudBackend, RestApi restApi, IInfrastructureEnvironment environment) { Container = cloudBackend.System.AddContainer( name: "User interface", description: "Visualizes the data, dashboarding etc.", technology: "Azure App Service"); Infrastructure = new WebAppService { Name = "ref-ui-" + environment.Name, EnvironmentInvariantName = "ref-ui" }; Uses(restApi).Over <Https>().InOrderTo("Load data"); }
public DeviceProvisioning(CloudBackend cloudBackend, CloudGateway hub, IInfrastructureEnvironment environment) { Container = cloudBackend.System.AddContainer( name: "Device Provisioning", description: "Provision device identities into the cloud gateway", technology: "Azure Device Provisioning Service"); Infrastructure = new DeviceProvisioningService { Name = "ref-dps-" + environment.Name }; Uses(hub).InOrderTo("Register provisioned Devices"); }
public TelemetryStorage(CloudBackend cloudBackend, IInfrastructureEnvironment environment) { Container = cloudBackend.System.AddContainer( name: "Telemetry Storage", description: "Stores all telemetry data from the devices", technology: "Azure Table Storage"); Infrastructure = new StorageAccount { Kind = StorageAccountKind.StorageV2, Name = "reftelemetry" + environment.Name, EnvironmentInvariantName = "reftelemetry" }; }
public StreamAnalytics(CloudBackend cloudBackend, SanitizedMessages sanitizedMessages, TelemetryStorage telemetryStorage, IInfrastructureEnvironment environment) { Container = cloudBackend.System.AddContainer( name: "Stream Analytics", description: "Analyzes the incoming event stream for anomalies", technology: "Azure Stream Analytics"); Infrastructure = new Structurizr.InfrastructureAsCode.Azure.Model.StreamAnalytics { Name = "ref-sa-" + environment.Name }; Uses(sanitizedMessages).Over(Infrastructure.EventHubInput("messages", sanitizedMessages.Infrastructure)).InOrderTo("Process incoming events"); Uses(telemetryStorage).Over(Infrastructure.TableStorageOutput("out", telemetryStorage.Infrastructure, "aggregated", "partitionKey", "rowKey")).InOrderTo("Store aggregated data"); Infrastructure.TransformationQuery = "SELECT\r\n *\r\nINTO\r\n out\r\nFROM\r\n iothub"; }
public RestApi(CloudBackend cloudBackend, TelemetryStorage telemetryStorage, MasterDataStorage masterDataStorage, ApplicationInsights applicationInsights, IInfrastructureEnvironment environment) { Container = cloudBackend.System.AddContainer( name: "REST Api", description: "Implements endpoint required by the UI to load data", technology: "Azure App Service"); Infrastructure = new WebAppService { Name = "ref-api-" + environment.Name, EnvironmentInvariantName = "ref-api" }; Uses(telemetryStorage).Over(telemetryStorage.Infrastructure.TableEndpoint).InOrderTo("Load telemetry data"); Uses(masterDataStorage).InOrderTo("Load master data"); Uses(applicationInsights).InOrderTo("Log metrics"); }