Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/martins-vds/cancellable-isolated-function
https://github.com/martins-vds/cancellable-isolated-function
Last synced: 6 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/martins-vds/cancellable-isolated-function
- Owner: martins-vds
- License: mit
- Created: 2024-01-16T23:26:31.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-01-16T23:41:19.000Z (11 months ago)
- Last Synced: 2024-10-29T18:26:50.471Z (about 2 months ago)
- Language: C#
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Proof of Concept: Azure Function with Cancellation
This repository contains a proof of concept for an Azure Function that can be cancelled after a specified number of seconds.
## Prerequisites
Before running the Azure Function, make sure you have the following prerequisites installed:
- [Azure Functions Core Tools](https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local?tabs=windows%2Ccsharp%2Cbash)
## Getting Started
1. Clone this repository to your local machine:
```bash
git clone https://github.com/martins-vds/cancellable-isolated-function.git
```2. Navigate to the project directory:
```bash
cd cancellable-isolated-function
# Again
cd cancellable-isolated-function
```3. Run the Azure Function locally:
```bash
func start
```## Usage
To trigger the cancellation of the Azure Function after a specific number of seconds, send an HTTP GET request to the following endpoint:
```bash
http://localhost:7071/api/cancel-me?wait=10
```The `wait` query parameter specifies the number of seconds (between 1 and 30) to wait before completing the request. If the `wait` query parameter is not specified, the default value of 10 seconds is used.
When the Azure Function is cancelled before it completes, the following message is returned in the console:
```bash
Operation was cancelled. Reason: A task was canceled.
```However, if the Azure Function is not cancelled before it completes, the following message is returned:
```bash
Welcome to Azure Functions!
```