public MonkeyMessageProcessor(MonkeyFactory monkeyFactory, MonkeyHub hub, MonkeyCrmConnector crmConnector, MonkeyEventStore eventStore, IInfrastructureEnvironment environment) { Container = monkeyFactory.System.AddContainer( name: "Monkey Message Processor", description: "Reads incoming messages, checks for alert conditions, stores messages", technology: "Azure Function"); Infrastructure = new FunctionAppService { Name = "monkey-message-processor-" + environment.Name }; Uses(hub) .Over <IoTHubSDK>() .InOrderTo("Read incoming messages"); Uses(crmConnector) .Over(crmConnector.Infrastructure.Queue("monkey-alerts")) .InOrderTo("Notify the CRM system of production failures"); Uses(eventStore) .Over <Https>() .InOrderTo("Store incoming messages"); }
public CloudBackend(Workspace workspace, IInfrastructureEnvironment environment) { System = workspace.Model.AddSoftwareSystem( Location.Internal, "Azure IoT system", "Azure cloud based backend for processing data created on sensors / devices"); SecretStorage = new SecretStorage(this, environment); CloudGateway = new CloudGateway(this, environment); DeviceProvisioning = new DeviceProvisioning(this, CloudGateway, environment); TelemetryStorage = new TelemetryStorage(this, environment); ApplicationInsights = new ApplicationInsights(this, environment); MasterDataStorage = new MasterDataStorage(this, new SqlServer(environment), environment); SanitizedMessages = new SanitizedMessages(this, new EventHubNamespace(environment), environment); Ingress = new Ingress(this, CloudGateway, TelemetryStorage, MasterDataStorage, SanitizedMessages, ApplicationInsights, environment); StreamAnalytics = new StreamAnalytics(this, SanitizedMessages, TelemetryStorage, environment); RestApi = new RestApi(this, TelemetryStorage, MasterDataStorage, ApplicationInsights, environment); UserInterface = new UserInterface(this, RestApi, environment); Device = workspace.Model.AddSoftwareSystem(Location.External, "Device", "Sends data into the cloud"); Device.Uses(CloudGateway, "Send telemetry data and failure events", "MQTT"); Device.Uses(DeviceProvisioning, "Provision device", "HTTPS"); User = workspace.Model.AddPerson("User", "Person using the system to view data and take action on it"); User.Uses(UserInterface, "View devices and their raw and aggregated data"); StoreSecretsInKeyVault(); }
public MonkeyFactory(Workspace workspace, IInfrastructureEnvironment environment) { System = workspace.Model.AddSoftwareSystem( Location.Internal, "Monkey Factory", "Azure cloud based backend for processing data created during production of monkeys"); KeyVault = new MonkeyKeyVault(this, environment); Hub = new MonkeyHub(this, environment); CrmConnector = new MonkeyCrmConnector(this, environment); EventStore = new MonkeyEventStore(this, environment); UI = new MonkeyUI(this, EventStore, environment); MessageProcessor = new MonkeyMessageProcessor(this, Hub, CrmConnector, EventStore, environment); DPS = new MonkeyDeviceProvisioningService(this, Hub, environment); TechnicalSupportUser = workspace.Model.AddPerson("Technical support user", "Responds to incidents during monkey production"); TechnicalSupportUser.Uses(UI, "Gather information about system failures"); ProductionShiftLead = workspace.Model.AddPerson("Production Shift leader", "Monitors monkey production"); ProductionShiftLead.Uses(UI, "Monitor load on production systems"); MonkeyProductionLine = workspace.Model.AddSoftwareSystem(Location.External, "Production Line", "Produces the actual monkeys"); MonkeyProductionLine.Uses(Hub, "Send production telemetry data and failure events", "MQTT"); MonkeyProductionLine.Uses(DPS, "Provision device that produces monkeys", "HTTPS"); Crm = workspace.Model.AddSoftwareSystem(Location.External, "CRM", ""); Crm.Uses(CrmConnector, "Process failure events in order to create support tickets", "AMQP"); StoreSecretsInKeyVault(); }
public EventHubNamespace(IInfrastructureEnvironment environment) { Infrastructure = new Structurizr.InfrastructureAsCode.Azure.Model.EventHubNamespace { Name = "ref-events-" + environment.Name }; }
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 SqlServer(IInfrastructureEnvironment environment) { Infrastructure = new Structurizr.InfrastructureAsCode.Azure.Model.SqlServer { Name = "ref-sql-server-" + environment.Name, AdministratorLogin = "******", AdministratorPassword = "******" }; }
public SampleSystem(Workspace workspace, IInfrastructureEnvironment environment) { System = workspace.Model.AddSoftwareSystem("Sample", ""); Customer = workspace.Model.AddPerson(Location.External, "Customer", "Does stuff"); Api = new SampleApi(this); WebApplication = new SampleWebApplication(this, Api); Customer.Uses(WebApplication.Container, "does stuff"); Customer.Uses(System, "does stuff"); }
public MonkeyCrmConnector(MonkeyFactory monkeyFactory, IInfrastructureEnvironment environment) { Container = monkeyFactory.System.AddContainer( name: "Monkey CRM Connector", description: "Serves as communication channel between the monkey factory cloud and the on premise CRM system", technology: "Azure Service Bus"); Infrastructure = new ServiceBus { Name = "monkey-crm-service-bus-" + environment.Name, EnvironmentInvariantName = "monkey-crm-service-bus" }; }
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 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 MonkeyHub(MonkeyFactory monkeyFactory, IInfrastructureEnvironment environment) { Container = monkeyFactory.System.AddContainer( name: "Monkey Hub", description: "Receives incoming messages from the monkey factory production systems", technology: "Azure IoT Hub"); Infrastructure = new IoTHub { Name = "monkey-hub-" + environment.Name, EnvironmentInvariantName = "monkey-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 MonkeyKeyVault(MonkeyFactory monkeyFactory, IInfrastructureEnvironment environment) { Container = monkeyFactory.System.AddContainer( name: "Monkey Key Vault", description: "Keeps the secrets", technology: "HTTPS"); Infrastructure = new KeyVault() { Name = "monkey-keyvault-" + environment.Name, EnvironmentInvariantName = "monkey-keyvault" }; }
public MonkeyEventStore(MonkeyFactory monkeyFactory, IInfrastructureEnvironment environment) { Container = monkeyFactory.System.AddContainer( name: "Monkey Event Store", description: "Persistently stores all received monkey production telemetry and event data", technology: "Azure Blob Storage"); Infrastructure = new StorageAccount { Kind = StorageAccountKind.StorageV2, Name = "monkeyevents" + environment.Name, EnvironmentInvariantName = "monkeyevents" }; }
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 MonkeyDeviceProvisioningService(MonkeyFactory monkeyFactory, MonkeyHub hub, IInfrastructureEnvironment environment) { Container = monkeyFactory.System.AddContainer( name: "Monkey Device Provisioning Service", description: "Registeres to Device Provisioning Service", technology: "Azure Device Provisioning Service"); Infrastructure = new DeviceProvisioningService() { Name = "monkey-dps-" + environment.Name }; Uses(hub).InOrderTo("Provision Devices"); }
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 MonkeyUI(MonkeyFactory monkeyFactory, MonkeyEventStore eventStore, IInfrastructureEnvironment environment) { Container = monkeyFactory.System.AddContainer( name: "Monkey UI", description: "Visualizes the monkey factory data", technology: "Azure Web App Service"); Infrastructure = new WebAppService { Name = "monkey-ui-" + environment.Name }; Uses(eventStore) .Over <Https>() .InOrderTo("Load information about the monkey factory"); }
private static Workspace ArchitectureModel(IInfrastructureEnvironment environment) { var workspace = CreateWorkspace(); var iotReferenceArchModel = new CloudBackend(workspace, environment); var contextView = workspace.Views.CreateSystemContextView(iotReferenceArchModel.System, "Iot reference architecture with functions Context view", "Overview over the IoT reference architecture"); contextView.AddAllSoftwareSystems(); contextView.AddAllPeople(); var containerView = workspace.Views.CreateContainerView(iotReferenceArchModel.System, "Iot reference architecture with functions Container View", "Overview over the IoT reference architecture"); containerView.AddAllContainers(); containerView.AddAllPeople(); foreach (var systemContainer in iotReferenceArchModel.System.Containers) { containerView.AddNearestNeighbours(systemContainer); } return(workspace); }
private static Workspace ArchitectureModel(IInfrastructureEnvironment environment) { var workspace = CreateWorkspace(); var monkeyFactory = new MonkeyFactory(workspace, environment); var contextView = workspace.Views.CreateSystemContextView(monkeyFactory.System, "Monkey factory context view", "Overview over the monkey factory system"); contextView.AddAllSoftwareSystems(); contextView.AddAllPeople(); var containerView = workspace.Views.CreateContainerView(monkeyFactory.System, "Monkey factory Container View", "Overview over the monkey factory system architecture"); containerView.AddAllContainers(); containerView.AddAllPeople(); foreach (var systemContainer in monkeyFactory.System.Containers) { containerView.AddNearestNeighbours(systemContainer); } return(workspace); }
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"); }
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 string TargetLocation(IInfrastructureEnvironment environment, IHaveInfrastructure elementWithInfrastructure) { return(_location); }
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 string TargetResourceGroup(IInfrastructureEnvironment environment, IHaveInfrastructure elementWithInfrastructure) { return(_namingConvention(environment)); }