AZ-204 Integration Flashcards

1
Q

APIM Terminology:

A

Backend API: Contains the business logic to use
FrontendAPI: Abstraction for backend API

Operation: Operation that correlates a frontend operation to a corresponding backend request

Products: Products are how APIs are surfaced to developers. Products in API Management have one or more APIs, and are configured with a title, description, and terms of use. Products can be Open or Protected. Protected products must be subscribed to before they can be used, while open products can be used without a subscription. Subscription approval is configured at the product level and can either require administrator approval, or be auto-approved.

Subscription: Allows client to use frontend APi or products

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How to secure APi with subscriptions?

A

Use subscription keys:
- Keys are sent in the HTTP request headers or as a query string
- There is a primary and secondary key that can be used to avoid downtime

Use subscription key scopes:
- All API: Applies to every API accessible from the Gateway
- Single API: This scope applies to a single API and all of its endpoints
- Product: This scope applies to a specific product

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Secure API with Oauth?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How are API Management policies configured?

A

Xml document used to describe request and response:

inbound: Statements to be applied to the request
backend: Statements to be applied before the request is forwarded to the backend service
outbound: Statements to be applied to the response
on-error: Statements to be applied on an error

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

When to use event grid vs event hubs vs service bus?

A

Event Grid: Allows for reactive programming with events to React to status changes
Event Hubs: A Big data pipeline for events. Used for Telemetry and distributed data streaming.
Service Bus: Enterprise messaging solution used for Order processing and financial transactions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is event grid?

A

Azure Event Grid is an eventing backplane that enables event-driven, reactive programming. It uses the publish-subscribe model. Publishers emit events, but have no expectation about how the events are handled. Subscribers decide on which events they want to handle.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the 5 concepts of Event Grid?

A

events: An event is the smallest amount of information that fully describes something that happened in the system. Every event has common information like: source of the event, time the event took place, and unique identifier. Every event also has specific information that is only relevant to the specific type of event.

An event of size up to 64 KB is covered by General Availability (GA) Service Level Agreement (SLA). The support for an event of size up to 1 MB is currently in preview. Events over 64 KB are charged in 64-KB increments

event sources: An event source is where the event happens.

topics: An event source is where the event happens. Each event source is related to one or more event types. For example, Azure Storage is the event source for blob created events. IoT Hub is the event source for device created events. Your application is the event source for custom events that you define. Event sources are responsible for sending events to Event Grid. System topics are those generated by Azure services (don’t show up in subscription), custom topics are those generated by custom apps and third party topics (show up in azure subscription).

event subscriptions: A subscription tells Event Grid which events on a topic you’re interested in receiving. When creating the subscription, you provide an endpoint for handling the event.

event handlers: From an Event Grid perspective, an event handler is the place where the event is sent. The handler takes some further action to process the event.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is azure queue storage service? (use service bus most of the time)

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

SDK for azure queue storage?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the default APIM system groups?

A

Administrators - Azure subscription administrators are members of this group. Administrators manage API Management service instances, creating the APIs, operations, and products that are used by developers.

Developers - Authenticated developer portal users fall into this group. Developers are the customers that build applications using your APIs. Developers are granted access to the developer portal and build applications that call the operations of an API.

Guests - Unauthenticated developer portal users, such as prospective customers visiting the developer portal of an API Management instance fall into this group. They can be granted certain read-only access, such as the ability to view APIs but not call them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is an API gateway?

A

An API gateway sits between clients and services. It acts as a reverse proxy, routing requests from clients to services. It may also perform various cross-cutting tasks such as authentication, SSL termination, and rate limiting.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the 3 API gateway design patterns?

A

Gateway routing: Use the gateway as a reverse proxy to route requests to one or more backend services, using layer 7 routing. The gateway provides a single endpoint for clients, and helps to decouple clients from services.

Gateway aggregation: Use the gateway to aggregate multiple individual requests into a single request. This pattern applies when a single operation requires calls to multiple backend services. The client sends one request to the gateway. The gateway dispatches requests to the various backend services, and then aggregates the results and sends them back to the client. This helps to reduce chattiness between the client and the backend.

Gateway Offloading: Use the gateway to offload functionality from individual services to the gateway, particularly cross-cutting concerns. It can be useful to consolidate these functions into one place, rather than making every service responsible for implementing them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are some examples of functionality offloaded to an API gateway?

A

SSL termination
Authentication
IP allow/block list
Client rate limiting (throttling)
Logging and monitoring
Response caching
GZIP compression
Servicing static content

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are the event grid batched delivery?

A

Max events per batch - Maximum number of events Event Grid will deliver per batch. This number will never be exceeded, however fewer events may be delivered if no other events are available at the time of publish. Event Grid doesn’t delay events to create a batch if fewer events are available. Must be between 1 and 5,000.

Preferred batch size in kilobytes - Target ceiling for batch size in kilobytes. Similar to max events, the batch size may be smaller if more events aren’t available at the time of publish. It’s possible that a batch is larger than the preferred batch size if a single event is larger than the preferred size. For example, if the preferred size is 4 KB and a 10-KB event is pushed to Event Grid, the 10-KB event will still be delivered in its own batch rather than being dropped.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How to configure retry settings for event delivery?

A

Maximum number of attempts - The value must be an integer between 1 and 30. The default value is 30.
Event time-to-live (TTL) - The value must be an integer between 1 and 1440. The default value is 1440 minutes

When Event Grid can’t deliver an event within a certain time period or after trying to deliver the event a certain number of times, it can send the undelivered event to a storage account.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is Event grid dead lettering?

A

Event Grid dead-letters an event when one of the following conditions is met.

  • Event isn’t delivered within the time-to-live period.
  • The number of tries to deliver the event exceeds the limit.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What are the built in roles for access to events?

A

Event Grid Subscription Reader: Lets you read Event Grid event subscriptions.
Event Grid Subscription Contributor: Lets you manage Event Grid event subscription operations.
Event Grid Contributor: Lets you create and manage Event Grid resources.
Event Grid Data Sender: Lets you send events to Event Grid topics.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What are the permissions required for different event subscriptions?

A

System Topic: /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}

Custom Topic: /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.EventGrid/topics/{topic-name}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Which Azure services automatically handle webhook endpoint validation?

A

Azure Logic Apps with Event Grid Connector
Azure Automation via webhook
Azure Functions with Event Grid Trigger

20
Q

What are the event hub key components?

A

Event Hubs client: primary interface for developers interacting with the Event Hubs client library.
Event Hubs producer: type of client that serves as a source of telemetry data, diagnostics information, usage logs, or other log data, as part of an embedded device solution, a mobile device application, a game title running on a console or other device, some client or server based business solution, or a web site.
Event Hubs consumer: type of client which reads information from the Event Hub and allows processing of it. Processing may involve aggregation, complex computation and filtering. Processing may also involve distribution or storage of the information in a raw or transformed fashion.
partition: an ordered sequence of events that is held in an Event Hubs. Partitions are a means of data organization associated with the parallelism required by event consumers. Azure Event Hubs provides message streaming through a partitioned consumer pattern in which each consumer only reads a specific subset, or partition, of the message stream.
consumer group: a view of an entire Event Hubs. Consumer groups enable multiple consuming applications to each have a separate view of the event stream, and to read the stream independently at their own pace and from their own position. There can be at most 5 concurrent readers on a partition per consumer group; however it is recommended that there is only one active consumer for a given partition and consumer group pairing.
Event receivers:Any entity that reads event data from an Event Hubs. All Event Hubs consumers connect via the AMQP 1.0 session. The Event Hubs service delivers events through a session as they become available. All Kafka consumers connect via the Kafka protocol 1.0 and later.
Throughput units or processing units: Pre-purchased units of capacity that control the throughput capacity of Event Hubs.

21
Q

What is the event hub storage naming convention?

A

{Namespace}/{EventHub}/{PartitionId}/{Year}/{Month}/{Day}/{Hour}/{Minute}/{Second}

22
Q

What is an eventhubs throughput unit?

A

A single throughput unit allows 1 MB per second or 1000 events per second of ingress and twice that amount of egress.

23
Q

What is a checkpoint in eventhubs?

A

Checkpointing is a process by which an event processor marks or commits the position of the last successfully processed event within a partition. Marking a checkpoint is typically done within the function that processes the events and occurs on a per-partition basis within a consumer group.

24
Q

How can you authorize users in eventhubs?

A

managed identities, microsoft identity platform/azure AD, SAS

25
Q

How to inspect an eventhub?

A

var connectionString = “&laquo_space;CONNECTION STRING FOR THE EVENT HUBS NAMESPACE&raquo_space;”;
var eventHubName = “&laquo_space;NAME OF THE EVENT HUB&raquo_space;”;

await using (var producer = new EventHubProducerClient(connectionString, eventHubName))
{
string[] partitionIds = await producer.GetPartitionIdsAsync();
}

26
Q

How to publish to eventhub?

A

var connectionString = “&laquo_space;CONNECTION STRING FOR THE EVENT HUBS NAMESPACE&raquo_space;”;
var eventHubName = “&laquo_space;NAME OF THE EVENT HUB&raquo_space;”;

await using (var producer = new EventHubProducerClient(connectionString, eventHubName))
{
using EventDataBatch eventBatch = await producer.CreateBatchAsync();
eventBatch.TryAdd(new EventData(new BinaryData(“First”)));
eventBatch.TryAdd(new EventData(new BinaryData(“Second”)));

await producer.SendAsync(eventBatch); }
27
Q

How to read events from an EventHub?

A

var connectionString = “&laquo_space;CONNECTION STRING FOR THE EVENT HUBS NAMESPACE&raquo_space;”;
var eventHubName = “&laquo_space;NAME OF THE EVENT HUB&raquo_space;”;

string consumerGroup = EventHubConsumerClient.DefaultConsumerGroupName;

await using (var consumer = new EventHubConsumerClient(consumerGroup, connectionString, eventHubName))
{
using var cancellationSource = new CancellationTokenSource();
cancellationSource.CancelAfter(TimeSpan.FromSeconds(45));

await foreach (PartitionEvent receivedEvent in consumer.ReadEventsAsync(cancellationSource.Token))
{
    // At this point, the loop will wait for events to be available in the Event Hub.  When an event
    // is available, the loop will iterate with the event that was received.  Because we did not
    // specify a maximum wait time, the loop will wait forever unless cancellation is requested using
    // the cancellation token.
} }
28
Q

How to process events using an event processor client?

A

var cancellationSource = new CancellationTokenSource();
cancellationSource.CancelAfter(TimeSpan.FromSeconds(45));

var storageConnectionString = “&laquo_space;CONNECTION STRING FOR THE STORAGE ACCOUNT&raquo_space;”;
var blobContainerName = “&laquo_space;NAME OF THE BLOB CONTAINER&raquo_space;”;

var eventHubsConnectionString = “&laquo_space;CONNECTION STRING FOR THE EVENT HUBS NAMESPACE&raquo_space;”;
var eventHubName = “&laquo_space;NAME OF THE EVENT HUB&raquo_space;”;
var consumerGroup = “&laquo_space;NAME OF THE EVENT HUB CONSUMER GROUP&raquo_space;”;

Task processEventHandler(ProcessEventArgs eventArgs) => Task.CompletedTask;
Task processErrorHandler(ProcessErrorEventArgs eventArgs) => Task.CompletedTask;

var storageClient = new BlobContainerClient(storageConnectionString, blobContainerName);
var processor = new EventProcessorClient(storageClient, consumerGroup, eventHubsConnectionString, eventHubName);

processor.ProcessEventAsync += processEventHandler;
processor.ProcessErrorAsync += processErrorHandler;

await processor.StartProcessingAsync();

try
{
// The processor performs its work in the background; block until cancellation
// to allow processing to take place.

await Task.Delay(Timeout.Infinite, cancellationSource.Token); } catch (TaskCanceledException) {
// This is expected when the delay is canceled. }

try
{
await processor.StopProcessingAsync();
}
finally
{
// To prevent leaks, the handlers should be removed when processing is complete.

processor.ProcessEventAsync -= processEventHandler;
processor.ProcessErrorAsync -= processErrorHandler; }
29
Q

When should you use a Service Bus?

A
  • Your solution needs to receive messages without having to poll the queue. With Service Bus, you can achieve it by using a long-polling receive operation using the TCP-based protocols that Service Bus supports.
  • Your solution requires the queue to provide a guaranteed first-in-first-out (FIFO) ordered delivery.
  • Your solution needs to support automatic duplicate detection.
  • You want your application to process messages as parallel long-running streams (messages are associated with a stream using the session ID property on the message). - - In this model, each node in the consuming application competes for streams, as opposed to messages. When a stream is given to a consuming node, the node can examine the state of the application stream state using transactions.
  • Your solution requires transactional behavior and atomicity when sending or receiving multiple messages from a queue.
  • Your application handles messages that can exceed 64 KB but won’t likely approach the 256-KB limit.
30
Q

When should you use a Service Queue?

A
  • Your application must store over 80 gigabytes of messages in a queue.
  • Your application wants to track progress for processing a message in the queue. It’s useful if the worker processing a message crashes. Another worker can then use that information to continue from where the prior worker left off.
  • You require server side logs of all of the transactions executed against your queues.
31
Q

What are the differences between the standard and premium tier of Service Bus?

A

Standard: Variable throughput and latency, PAYG pricing, message size up to 256kb

Premium: high throughput, predictable performance, Fixed pricing, scale up/down, message size up to 100MB

32
Q

What are Service Bus Queues?

A

Queues offer First In, First Out (FIFO) message delivery to one or more competing consumers. That is, receivers typically receive and process messages in the order in which they were added to the queue. And, only one message consumer receives and processes each message.

A related benefit is load-leveling, which enables producers and consumers to send and receive messages at different rates.
Using queues to intermediate between message producers and consumers provides an inherent loose coupling between the components.

33
Q

What are Service Bus Topics?

A

Provide information of events like event grid

34
Q

What are Service Bus Subscriptions?

A

Subscribe to topics like event grid

35
Q

What are the 2 service bus receive modes?

A

Receive and Delete: In this mode, when Service Bus receives the request from the consumer, it marks the message as being consumed and returns it to the consumer application.

It works best for scenarios in which the application can tolerate not processing a message if a failure occurs. For example, consider a scenario in which the consumer issues the receive request and then crashes before processing it.

Peek Lock:

In this mode, the receive operation becomes two-stage, which makes it possible to support applications that can’t tolerate missing messages.

  • Finds the next message to be consumed, locks it to prevent other consumers from receiving it, and then, return the message to the application.
  • After the application finishes processing the message, it requests the Service Bus service to complete the second stage of the receive process. Then, the service marks the message as being consumed.

If the application is unable to process the message for some reason, it can request the Service Bus service to abandon the message. Service Bus unlocks the message and makes it available to be received again, either by the same consumer or by another competing consumer. Secondly, there’s a timeout associated with the lock. If the application fails to process the message before the lock timeout expires, Service Bus unlocks the message and makes it available to be received again.

36
Q

What are the components of the Queue Message Storage?

A

URL format: Queues are addressable using the URL format https://<storage>.queue.core.windows.net/<queue>. For example, the following URL addresses a queue in the diagram above https://myaccount.queue.core.windows.net/images-to-download</queue></storage>

Storage account: All access to Azure Storage is done through a storage account.

Queue: A queue contains a set of messages. All messages must be in a queue. Note that the queue name must be all lowercase.

Message: A message, in any format, of up to 64 KB. For version 2017-07-29 or later, the maximum time-to-live can be any positive number, or -1 indicating that the message doesn’t expire. If this parameter is omitted, the default time-to-live is seven days.

37
Q

How do you create a queue client for Queue Message Storage in C#?

A

QueueClient queueClient = new QueueClient(connectionString, queueName);

38
Q

How do you create a queue for Queue Message Storage in C#?

A

// Get the connection string from app settings
string connectionString = ConfigurationManager.AppSettings[“StorageConnectionString”];

// Instantiate a QueueClient which will be used to create and manipulate the queue
QueueClient queueClient = new QueueClient(connectionString, queueName);

// Create the queue
queueClient.CreateIfNotExists();

39
Q

How do you insert a message into a queue for Queue Message Storage in C#?

A

// Get the connection string from app settings
string connectionString = ConfigurationManager.AppSettings[“StorageConnectionString”];

// Instantiate a QueueClient which will be used to create and manipulate the queue
QueueClient queueClient = new QueueClient(connectionString, queueName);

// Create the queue if it doesn’t already exist
queueClient.CreateIfNotExists();

if (queueClient.Exists())
{
// Send a message to the queue
queueClient.SendMessage(message);
}

40
Q

How do you peek at the next message in a queue for Queue Message Storage in C#?

A

// Get the connection string from app settings
string connectionString = ConfigurationManager.AppSettings[“StorageConnectionString”];

// Instantiate a QueueClient which will be used to manipulate the queue
QueueClient queueClient = new QueueClient(connectionString, queueName);

if (queueClient.Exists())
{
// Peek at the next message
PeekedMessage[] peekedMessage = queueClient.PeekMessages();
}

41
Q

How do you change the content of a queued message for Queue Message Storage in C#?

A

// Get the connection string from app settings
string connectionString = ConfigurationManager.AppSettings[“StorageConnectionString”];

// Instantiate a QueueClient which will be used to manipulate the queue
QueueClient queueClient = new QueueClient(connectionString, queueName);

if (queueClient.Exists())
{
// Get the message from the queue
QueueMessage[] message = queueClient.ReceiveMessages();

// Update the message contents
queueClient.UpdateMessage(message[0].MessageId, 
        message[0].PopReceipt, 
        "Updated contents",
        TimeSpan.FromSeconds(60.0)  // Make it invisible for another 60 seconds
    ); }
42
Q

How do you dequeue the next message for Queue Message Storage in C#?

A

// Get the connection string from app settings
string connectionString = ConfigurationManager.AppSettings[“StorageConnectionString”];

// Instantiate a QueueClient which will be used to manipulate the queue
QueueClient queueClient = new QueueClient(connectionString, queueName);

if (queueClient.Exists())
{
// Get the next message
QueueMessage[] retrievedMessage = queueClient.ReceiveMessages();

// Process (i.e. print) the message in less than 30 seconds
Console.WriteLine($"Dequeued message: '{retrievedMessage[0].Body}'");

// Delete the message
queueClient.DeleteMessage(retrievedMessage[0].MessageId, retrievedMessage[0].PopReceipt); }
43
Q

How do you get the queue length for Queue Message Storage in C#?

A

/// Instantiate a QueueClient which will be used to manipulate the queue
QueueClient queueClient = new QueueClient(connectionString, queueName);

if (queueClient.Exists())
{
QueueProperties properties = queueClient.GetProperties();

// Retrieve the cached approximate message count.
int cachedMessagesCount = properties.ApproximateMessagesCount;

// Display number of messages.
Console.WriteLine($"Number of messages in queue: {cachedMessagesCount}"); }
44
Q

How do you delete a queue for Queue Message Storage in C#?

A

/// Get the connection string from app settings
string connectionString = ConfigurationManager.AppSettings[“StorageConnectionString”];

// Instantiate a QueueClient which will be used to manipulate the queue
QueueClient queueClient = new QueueClient(connectionString, queueName);

if (queueClient.Exists())
{
// Delete the queue
queueClient.Delete();
}

45
Q

What are common service bus situations and the properties used in them?

A

A subset of the broker properties described previously, specifically To, ReplyTo, ReplyToSessionId, MessageId, CorrelationId, and SessionId, are used to help applications route messages to particular destinations. To illustrate this, consider a few patterns:

Simple request/reply: A publisher sends a message into a queue and expects a reply from the message consumer. To receive the reply, the publisher owns a queue into which it expects replies to be delivered. The address of that queue is expressed in the ReplyTo property of the outbound message. When the consumer responds, it copies the MessageId of the handled message into the CorrelationId property of the reply message and delivers the message to the destination indicated by the ReplyTo property. One message can yield multiple replies, depending on the application context.

Multicast request/reply: As a variation of the prior pattern, a publisher sends the message into a topic and multiple subscribers become eligible to consume the message. Each of the subscribers might respond in the fashion described previously. This pattern is used in discovery or roll-call scenarios and the respondent typically identifies itself with a user property or inside the payload. If ReplyTo points to a topic, such a set of discovery responses can be distributed to an audience.

Multiplexing: This session feature enables multiplexing of streams of related messages through a single queue or subscription such that each session (or group) of related messages, identified by matching SessionId values, are routed to a specific receiver while the receiver holds the session under lock. Learn more about the details of sessions here.

Multiplexed request/reply: This session feature enables multiplexed replies, allowing several publishers to share a reply queue. By setting ReplyToSessionId, the publisher can instruct the consumer(s) to copy that value into the SessionId property of the reply message. The publishing queue or topic does not need to be session-aware. As the message is sent, the publisher can then specifically wait for a session with the given SessionId to materialize on the queue by conditionally accepting a session receiver.

46
Q

Service Bus Filters?

A

SQL Filters - A SqlFilter holds a SQL-like conditional expression that is evaluated in the broker against the arriving messages’ user-defined properties and system properties. All system properties must be prefixed with sys. in the conditional expression. The SQL-language subset for filter conditions tests for the existence of properties (EXISTS), null-values (IS NULL), logical NOT/AND/OR, relational operators, simple numeric arithmetic, and simple text pattern matching with LIKE.

Boolean filters - The TrueFilter and FalseFilter either cause all arriving messages (true) or none of the arriving messages (false) to be selected for the subscription. These two filters derive from the SQL filter.

Correlation Filters - A CorrelationFilter holds a set of conditions that are matched against one or more of an arriving message’s user and system properties. A common use is to match against the CorrelationId property, but the application can also choose to match against the following properties:
A match exists when an arriving message’s value for a property is equal to the value specified in the correlation filter. For string expressions, the comparison is case-sensitive. If you specify multiple match properties, the filter combines them as a logical AND condition, meaning for the filter to match, all conditions must match.

47
Q

Event vs Message?

A

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.

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