Skip to content

Instantly share code, notes, and snippets.

@leoricklin
Last active August 26, 2022 10:32
Show Gist options
  • Save leoricklin/f4a59a1f1028a4a423099a8a9407d204 to your computer and use it in GitHub Desktop.
Save leoricklin/f4a59a1f1028a4a423099a8a9407d204 to your computer and use it in GitHub Desktop.

Azure

.Net Architecture

Microservices

  • Introduction to Containersand Docker
  • Choosing Between .NET 5 and .NET Framework for Docker Containers
  • Architecting Container and Microservice Based Applications
  • Development Process for Docker Based Applications
  • Designing and Developing Multi Container and Microservice Based .NET Applications
  • Tackling Business Complexity in a Microservice with DDD and CQRS Patterns
  • Implementing Resilient Applications
  • Securing .NET Microservices and Web Applications
  • Key takeaways
Patterns Summary
Cache-Aside Load data on demand into a cache from a data store
CQRS Segregate operations that read data from operations that update data by using separate interfaces.
Event Sourcing Use an append-only store to record the full series of events that describe actions taken on data in a domain.
Index Table Create indexes over the fields in data stores that are frequently referenced by queries.
Materialized View Generate prepopulated views over the data in one or more data stores when the data isn't ideally formatted for required query operations.
Sharding Divide a data store into a set of horizontal partitions or shards.
Static Content Hosting Deploy static content to a cloud-based storage service that can deliver them directly to the client.
Valet Key Use a token or key that provides clients with restricted direct access to a specific resource or service.

Challenges in cloud development: Design and Implementation

Patterns Summary
Ambassador Create helper services that send network requests on behalf of a consumer service or application.
Anti-Corruption Layer Implement a façade or adapter layer between a modern application and a legacy system.
Backends for Frontends Create separate backend services to be consumed by specific frontend applications or interfaces.
CQRS Segregate operations that read data from operations that update data by using separate interfaces.
Compute Resource Consolidation Consolidate multiple tasks or operations into a single computational unit
External Configuration Store Move configuration information out of the application deployment package to a centralized location.
Gateway Aggregation Use a gateway to aggregate multiple individual requests into a single request.
Gateway Offloading Offload shared or specialized service functionality to a gateway proxy.
Gateway Routing Route requests to multiple services using a single endpoint.
Leader Election Coordinate the actions performed by a collection of collaborating task instances in a distributed application by electing one instance as the leader that assumes responsibility for managing the other instances.
Pipes and Filters Break down a task that performs complex processing into a series of separate elements that can be reused.
Sidecar Deploy components of an application into a separate process or container to provide isolation and encapsulation.
Static Content Hosting Deploy static content to a cloud-based storage service that can deliver them directly to the client.
Strangler Fig Incrementally migrate a legacy system by gradually replacing specific pieces of functionality with new applications and services.

Challenges in cloud development: Messaging

Patterns Summary
Asynchronous Request-Reply Decouple backend processing from a frontend host, where backend processing needs to be asynchronous, but the frontend still needs a clear response.
Claim Check Split a large message into a claim check and a payload to avoid overwhelming a message bus.
Choreography Have each component of the system participate in the decision-making process about the workflow of a business transaction, instead of relying on a central point of control.
Competing Consumers Enable multiple concurrent consumers to process messages received on the same messaging channel.
Pipes and Filters Break down a task that performs complex processing into a series of separate elements that can be reused.
Priority Queue Prioritize requests sent to services so that requests with a higher priority are received and processed more quickly than those with a lower priority.
Publisher-Subscriber Enable an application to announce events to multiple interested consumers asynchronously, without coupling the senders to the receivers.
Queue-Based Load Leveling Use a queue that acts as a buffer between a task and a service that it invokes in order to smooth intermittent heavy loads.
Scheduler Agent Supervisor Coordinate a set of actions across a distributed set of services and other remote resources.
Sequential Convoy Process a set of related messages in a defined order, without blocking processing of other groups of messages.

Learn

Messaging Service

Service Bus Messaging

Overview
  • 20210216 What is Azure Service Bus, https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-messaging-overview
    • Concepts and terminology

      • Queues

        Messages are sent to and received from queues. Queues store messages until the receiving application is available to receive and process them.

      • Topics

        You can also use topics to send and receive messages. While a queue is often used for point-to-point communication, topics are useful in publish/subscribe scenarios.

    • Integration

      Service Bus fully integrates with many Microsoft and Azure services, for instance:

      • Event Grid
      • Logic Apps
      • Azure Functions
      • Power Platform
      • Dynamics 365
      • Azure Stream Analytics

Resources

  • 20200707 Choose between Azure messaging services - Event Grid, Event Hubs, and Service Bus, https://docs.microsoft.com/en-us/azure/event-grid/compare-messaging-services?toc=/azure/service-bus-messaging/toc.json

    Event

    An event is a lightweight notification of a condition or a state change. The publisher of the event has no expectation about how the event is handled. The consumer of the event decides what to do with the notification. Events can be discrete units or part of a series.

    Discrete events report state change and are actionable. To take the next step, the consumer only needs to know that something happened. The event data has information about what happened but doesn't have the data that triggered the event. For example, an event notifies consumers that a file was created. It may have general information about the file, but it doesn't have the file itself. Discrete events are ideal for serverless solutions that need to scale.

    Message

    A message is raw data produced by a service to be consumed or stored elsewhere. The message contains the data that triggered the message pipeline. The publisher of the message has an expectation about how the consumer handles the message. A contract exists between the two sides. For example, the publisher sends a message with the raw data, and expects the consumer to create a file from that data and send a response when the work is done.

    Comparison of services

Service Purpose Type When to use
Event Grid Reactive programming Event distribution (discrete) React to status changes
Event Hubs Big data pipeline Event streaming (series) Telemetry and distributed data streaming
Service Bus High-value enterprise messaging Message Order processing and financial transactions

Serverless

Functions

Overview
X Durable Functions Logic Apps
Development Code-first (imperative) Designer-first (declarative)
Connectivity About a dozen built-in binding types, write code for custom bindings Large collection of connectors, Enterprise Integration Pack for B2B scenarios, build custom connectors
Actions Each activity is an Azure function; write code for activity functions Large collection of ready-made actions
Monitoring Azure Application Insights Azure portal, Azure Monitor logs
Management REST API, Visual Studio Azure portal, REST API, PowerShell, Visual Studio
Execution context Can run locally or in the cloud Runs only in the cloud

Storage

Guides

  • Introduction to Azure Blob storage, https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blobs-introduction

    Blob storage resources

    Blob storage offers three types of resources:

    • The storage account
    • A container in the storage account
    • A blob in a container

    The following diagram shows the relationship between these resources.

    Storage accounts

    A storage account provides a unique namespace in Azure for your data. Every object that you store in Azure Storage has an address that includes your unique account name. The combination of the account name and the Azure Storage blob endpoint forms the base address for the objects in your storage account.

    Containers

    A container organizes a set of blobs, similar to a directory in a file system. A storage account can include an unlimited number of containers, and a container can store an unlimited number of blobs.

    Blobs

    Azure Storage supports three types of blobs:

    • Block blobs store text and binary data. Block blobs are made up of blocks of data that can be managed individually. Block blobs can store up to about 190.7 TiB.
    • Append blobs are made up of blocks like block blobs, but are optimized for append operations. Append blobs are ideal for scenarios such as logging data from virtual machines.
    • Page blobs store random access files up to 8 TiB in size. Page blobs store virtual hard drive (VHD) files and serve as disks for Azure virtual machines. For more information about page blobs, see Overview of Azure page blobs
  • Grant limited access to Azure Storage resources using shared access signatures (SAS), https://docs.microsoft.com/en-us/azure/storage/common/storage-sas-overview

    A common scenario where a SAS is useful is a service where users read and write their own data to your storage account. In a scenario where a storage account stores user data, there are two typical design patterns:

    • Clients upload and download data via a front-end proxy service, which performs authentication. This front-end proxy service allows the validation of business rules. But for large amounts of data, or high-volume transactions, creating a service that can scale to match demand may be expensive or difficult.

    • A lightweight service authenticates the client as needed and then generates a SAS. Once the client application receives the SAS, it can access storage account resources directly. Access permissions are defined by the SAS and for the interval allowed by the SAS. The SAS mitigates the need for routing all data through the front-end proxy service.

Resources

Resource Type of Blob Limit
Maximum size of single blob container 5 PB
Maximum number of blocks Block / Append 50,000
Maximum block size Block 100 MB
Maximum total block size Append 4 MiB
Maximum total blob size Block Approx. 4.75 TB
Maximum total blob size Append Approximately 195 GB
Maximum total blob size Page 8 TB
Maximum stored access policies per container All 5
Target request rate for blob All 500/second
Target throughput for blob Page 60 MB/s
Target throughput for blob Block Depends on storage account ingress/egress limits

Visual Studio

  • Part 1: Getting started
  • Part 2: The application
  • Part 3: Update your app
  • Part 4: Share your app
  • Part 5: Persist your database
  • Part 6: Use bind mounts
  • Part 7: Multi-container apps
  • Part 8: Use Docker Compose
  • Part 9: Image-building best practices
  • Part 10: Deploy to the cloud
  • What's next?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment