1595388300
Cancelling in-progress network operations is critical for applications to maintain responsiveness and avoid doing work that isn’t needed anymore. There are many situations where you want to cancel on-going work, for example when you are:
The new Azure SDK libraries for JavaScript and TypeScript have adopted abort signals situations like these.
AbortController
and AbortSignal
are standard features in the browser and are used with the fetch API to abort in-progress network requests. The controller is responsible for triggering the cancellation, and signals are responsible for notifying when a cancellation has been triggered. This separation of concerns enables you to safely pass the abort signal to other parts of your application without worrying about it unintentionally cancelling the request.
If you’re only targeting fairly modern browsers, you can use the built-in AbortController
and AbortSignal
and everything will work fine. If you’re targeting Node.js, or if you want to take advantage of linked signals or other features that I’ll cover later in this post, you can use the implementation in the Azure SDK found in the @azure/abort-controller npm package.
To abort an in-progress request such as an upload or download in storage, create a new AbortController
and pass its signal into the method you might want to cancel later:
// Omit this line if you want to use the AbortSignal built into the browser.
import { AbortController } from "@azure/abort-controller";
// create a controller and get its signal
const controller = new AbortController();
const abortSignal = controller.signal;
// pass the abortSignal into the API you want to cancel
await blobClient.download({ abortSignal })
// then sometime later, cancel it!
controller.abort();
Note that cancelling using AbortController
only affects client-side code. It does not notify the service that cancellation has happened. For example, if you are uploading a key into Key Vault and you cancel before it finishes, the key might still be created.
#azure sdk #javascript #programming #typescript
1624342320
Welcome to the June release of the Azure SDK. We have updated the following libraries:
JsonWebKey
.#azure sdk #azure #azure-sdk #javascript #python #release #sdk
1595388300
Cancelling in-progress network operations is critical for applications to maintain responsiveness and avoid doing work that isn’t needed anymore. There are many situations where you want to cancel on-going work, for example when you are:
The new Azure SDK libraries for JavaScript and TypeScript have adopted abort signals situations like these.
AbortController
and AbortSignal
are standard features in the browser and are used with the fetch API to abort in-progress network requests. The controller is responsible for triggering the cancellation, and signals are responsible for notifying when a cancellation has been triggered. This separation of concerns enables you to safely pass the abort signal to other parts of your application without worrying about it unintentionally cancelling the request.
If you’re only targeting fairly modern browsers, you can use the built-in AbortController
and AbortSignal
and everything will work fine. If you’re targeting Node.js, or if you want to take advantage of linked signals or other features that I’ll cover later in this post, you can use the implementation in the Azure SDK found in the @azure/abort-controller npm package.
To abort an in-progress request such as an upload or download in storage, create a new AbortController
and pass its signal into the method you might want to cancel later:
// Omit this line if you want to use the AbortSignal built into the browser.
import { AbortController } from "@azure/abort-controller";
// create a controller and get its signal
const controller = new AbortController();
const abortSignal = controller.signal;
// pass the abortSignal into the API you want to cancel
await blobClient.download({ abortSignal })
// then sometime later, cancel it!
controller.abort();
Note that cancelling using AbortController
only affects client-side code. It does not notify the service that cancellation has happened. For example, if you are uploading a key into Key Vault and you cancel before it finishes, the key might still be created.
#azure sdk #javascript #programming #typescript
1622036598
JavaScript is unarguablly one of the most common things you’ll learn when you start programming for the web. Here’s a small post on JavaScript compound assignment operators and how we use them.
The compound assignment operators consist of a binary operator and the simple assignment operator.
The binary operators, work with two operands. For example a+b where + is the operator and the a, b are operands. Simple assignment operator is used to assign values to a variable(s).
It’s quite common to modify values stored in variables. To make this process a little quicker, we use compound assignment operators.
They are:
You can also check my video tutorial compound assignment operators.
Let’s consider an example. Suppose price = 5 and we want to add ten more to it.
var price = 5;
price = price + 10;
We added ten to price. Look at the repetitive price variable. We could easily use a compound += to reduce this. We do this instead.
price += 5;
Awesome. Isn’t it? What’s the value of price now? Practice and comment below. If you don’t know how to practice check these lessons.
Lets bring down the price by 5 again and display it.
We use console.log command to display what is stored in the variable. It is very help for debugging.
Debugging let’s you find errors or bugs in your code. More on this later.
price -= 5;
console.log(price);
Lets multiply price and show it.
price *=5;
console.log(price);
and finally we will divide it.
price /=5;
console.log(price);
If you have any doubts, comment below.
#javascript #javascript compound assignment operators #javascript binary operators #javascript simple assignment operator #doers javascript
1595338560
A common feature in cloud APIs is paging for list results. Result sets may be massive – you could have thousands of blobs in a container, for example. Getting all results at once can cause delays in transmission and excessive load on the backend, and might even be so big it won’t fit into memory in your client. So services offer potentially large collections in pages and developers request one page of results at a time.
The Azure SDK for Javascript and TypeScript abstracts away the details of requesting pages from the service. You write a normal loop, and we take care of the rest. For example, here is the code that iterates through a list of containers in Storage:
const containers = blobServiceClient.listContainers();
for await (const container of containers) {
console.log(`Container: ${container.name}`);
}
How is this done? We use features that were added to recent editions of JavaScript; most notably async iterators. Async Iterators represent a stream of data that is loaded asynchronously. They are used across the Azure SDK to represent asynchronous streams of data such as paginated APIs like above.
Async Iterators, the Async Generators that produce them, and the for - await - of loops loops that consume them were added in the ES2018 edition of the JavaScript standard. They are supported natively in recent version of modern browsers, but TypeScript can compile them down to previous versions of JavaScript.
If you’re already familiar with async functions, promises, generators, and iterators, feel free to skip the background below. If not, that’s great, most of this blog is for you!
#azure sdk #javascript #typescript #programming
1597820400
Thank you for your interest in the new Azure SDKs! We release new features, improvements, and bug fixes every month. Please subscribe to our Azure SDK Blog RSS Feed to get notified when a new release is available.
You can find links to packages, code, and docs on our Azure SDK Releases page.
FieldBuilder
to help easily build a search index from a model type.We are open to Azure SDK blog contributions and invite you to be a guest blogger. Please contact us at azsdkblog@microsoft.com with your topic and we’ll get you setup.
#azure sdk #.net #java #javascript #python #release #sdk #typescript