Skip to content

Commit 4ed6471

Browse files
Merge pull request #88291 from craigshoemaker/crs-functions-idempotent
Add new Functions article: Idempotency in Azure Functions
2 parents 3b89b7b + 89514d4 commit 4ed6471

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

articles/azure-functions/TOC.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@
9898
href: functions-premium-plan.md
9999
- name: Deployments
100100
href: functions-deployment-technologies.md
101+
- name: Events and messaging
102+
items:
103+
- name: Designing for identical input
104+
href: functions-idempotent.md
101105
- name: Triggers and bindings
102106
items:
103107
- name: About triggers and bindings
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
title: Designing Azure Functions for identical input
3+
description: Building Azure Functions to be idempotent
4+
author: craigshoemaker
5+
ms.author: cshoe
6+
ms.date: 9/12/2019
7+
ms.topic: article
8+
ms.service: azure-functions
9+
manager: gwallace
10+
---
11+
12+
# Designing Azure Functions for identical input
13+
14+
The reality of event-driven and message-based architecture dictates the need to accept identical requests while preserving data integrity and system stability.
15+
16+
To illustrate, consider an elevator call button. As you press the button, it lights up and an elevator is sent to your floor. A few moments later, someone else joins you in the lobby. This person smiles at you and presses the illuminated button a second time. You smile back and chuckle to yourself as you're reminded that the command to call an elevator is idempotent.
17+
18+
Pressing an elevator call button a second, third, or fourth time has no bearing on the final result. When you press the button, regardless of the number of times, the elevator is sent to your floor. Idempotent systems, like the elevator, result in the same outcome no matter how many times identical commands are issued.
19+
20+
When it comes to building applications, consider the following scenarios:
21+
22+
- What happens if your inventory control application tries to delete the same product more than once?
23+
- How does your human resource application behave if there is more than one request to create an employee record for the same person?
24+
- Where does the money go if your banking app gets 100 requests to make the same withdrawal?
25+
26+
There are many contexts where requests to a function may receive identical commands. Some situations include:
27+
28+
- Retry policies sending the same request many times
29+
- Cached commands replayed to the application
30+
- Application errors sending multiple identical requests
31+
32+
To protect data integrity and system health, an idempotent application contains logic that may contain the following behaviors:
33+
34+
- Verifying of the existence of data before trying to execute a delete
35+
- Checking to see if data already exists before trying to execute a create action
36+
- Reconciling logic that creates eventual consistency in data
37+
- Concurrency controls
38+
- Duplication detection
39+
- Data freshness validation
40+
- Guard logic to verify input data
41+
42+
Ultimately idempotency is achieved by ensuring a given action is possible and is only executed once.

0 commit comments

Comments
 (0)