Skip to content

Commit

Permalink
feat: add support for managed identities (#61)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: replaces `TaskClient.create` with `TaskClient.createFromKey` and `TaskClient.createFromCredential`
  • Loading branch information
ethanperry1 authored Apr 12, 2024
1 parent 9759f5e commit 6903aef
Show file tree
Hide file tree
Showing 14 changed files with 15,651 additions and 14,241 deletions.
403 changes: 403 additions & 0 deletions .eslintrc.js

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,23 @@ const util = require('util');

async function main() {
// Set up the client
const client = await TaskClient.create(
const client = await TaskClient.createFromKey(
'https://your-cosmos-account.documents.azure.com:443/',
'your-cosmos-database',
'your-cosmos-collection', // Will be created if it doesn't exist
'base64-encoded key'
);

/*
* // Alternatively initialize the client with a managed identity.
* const client = await TaskClient.createFromCredential(
* 'https://your-cosmos-account.documents.azure.com:443/',
* 'your-cosmos-database',
* 'your-cosmos-collection', // Will be created if it doesn't exist
* new ChainedTokenCredential(...) // From @azure/identity library.
* );
*/

// Create a task that runs once
const task = await client.create('sample-task', { hello: 'world' });

Expand Down Expand Up @@ -104,7 +114,7 @@ Let's break down what's going on in here:
Before we get going, we need a client to work with.

```js
const client = await TaskClient.create(
const client = await TaskClient.createFromKey(
'https://your-cosmos-account.documents.azure.com:443/',
'your-cosmos-database', // Will be created if it doesn't exist
'your-cosmos-collection', // Will be created if it doesn't exist
Expand Down
Loading

0 comments on commit 6903aef

Please sign in to comment.