You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/cognitive-services/video-indexer/video-indexer-use-apis.md
+7-3Lines changed: 7 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,9 +50,13 @@ Once you subscribed to the Authorization API, you will be able to obtain access
50
50
51
51
Each call to the Operations API should be associated with an access token, matching the authorization scope of the call.
52
52
53
-
- User level - user level access tokens let you perform operations on the user level. For example, get associated accounts.
54
-
- Account level – account level access tokens let you perform operations on the account level. for example, Upload video, list all videos, create a language model, etc.
55
-
- Video level – video level access tokens let you perform operations on specific videos. for example, get video insights, download captions, get widgets, etc.
53
+
- User level - user level access tokens let you perform operations on the **user** level. For example, get associated accounts.
54
+
- Account level – account level access tokens let you perform operations on the **account** level or the **video** level. For example, Upload video, list all videos, get video insights, etc.
55
+
- Video level – video level access tokens let you perform operations on a specific **video**. For example, get video insights, download captions, get widgets, etc.
56
+
57
+
You can control whether these tokens are readonly or they allow editing by specifying **allowEdit=true/false**.
58
+
59
+
For most server-to-server scenarios, you will probably use the same **account** token since it covers both **account** operations and **video** operations. However, if you are planning to make client side calls to Video Indexer (e.g. from javascript), you would want to use a **video** access token, to prevent clients from getting access to the entire account. That is also the reason that when embedding VideoIndexer client code in your client (e.g. using **Get Insights Widget** or **Get Player Widget**) you must provide a **video** access token.
56
60
57
61
To make things easier, you can use the **Authorization** API > **GetAccounts** to get your accounts without obtaining a user token first. You can also ask to get the accounts with valid tokens, enabling you to skip an additional call to get an account token.
Copy file name to clipboardExpand all lines: articles/cosmos-db/sql-api-nodejs-get-started.md
+42-39Lines changed: 42 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,15 +15,14 @@ ms.author: sngun
15
15
16
16
---
17
17
# Node.js tutorial: Use the SQL API in Azure Cosmos DB to create a Node.js console application
18
+
18
19
> [!div class="op_single_selector"]
19
20
> *[.NET](sql-api-get-started.md)
20
21
> *[.NET Core](sql-api-dotnetcore-get-started.md)
21
22
> *[Node.js for MongoDB](mongodb-samples.md)
22
23
> *[Node.js](sql-api-nodejs-get-started.md)
23
24
> *[Java](sql-api-java-get-started.md)
24
25
> *[C++](sql-api-cpp-get-started.md)
25
-
>
26
-
>
27
26
28
27
Welcome to the Node.js tutorial for the Azure Cosmos DB Node.js SDK! After following this tutorial, you'll have a console application that creates and queries Azure Cosmos DB resources.
29
28
@@ -46,6 +45,7 @@ After you've completed the Node.js tutorial, please use the voting buttons at th
46
45
Now let's get started!
47
46
48
47
## Prerequisites for the Node.js tutorial
48
+
49
49
Please make sure you have the following:
50
50
51
51
* An active Azure account. If you don't have one, you can sign up for a [Free Azure Trial](https://azure.microsoft.com/pricing/free-trial/).
@@ -55,11 +55,13 @@ Please make sure you have the following:
55
55
*[Node.js](https://nodejs.org/) version v0.10.29 or higher.
56
56
57
57
## Step 1: Create an Azure Cosmos DB account
58
+
58
59
Let's create an Azure Cosmos DB account. If you already have an account you want to use, you can skip ahead to [Set up your Node.js application](#SetupNode). If you are using the Azure Cosmos DB Emulator, please follow the steps at [Azure Cosmos DB Emulator](local-emulator.md) to setup the emulator and skip ahead to [Set up your Node.js application](#SetupNode).
## <aid="SetupNode"></a>Step 2: Set up your Node.js application
64
+
63
65
1. Open your favorite terminal.
64
66
2. Locate the folder or directory where you'd like to save your Node.js application.
65
67
3. Create two empty JavaScript files with the following commands:
@@ -75,6 +77,7 @@ Let's create an Azure Cosmos DB account. If you already have an account you want
75
77
Great! Now that you've finished setting up, let's start writing some code.
76
78
77
79
## <aid="Config"></a>Step 3: Set your app's configurations
80
+
78
81
Open ```config.js``` in your favorite text editor.
79
82
80
83
Then, copy and paste the code snippet below and set properties ```config.endpoint``` and ```config.primaryKey``` to your Azure Cosmos DB endpoint uri and primary key. Both these configurations can be found in the [Azure portal](https://portal.azure.com).
@@ -158,7 +161,6 @@ Copy and paste the ```database id```, ```collection id```, and ```JSON documents
158
161
}
159
162
};
160
163
161
-
162
164
The database, collection, and document definitions will act as your Azure Cosmos DB ```database id```, ```collection id```, and documents' data.
163
165
164
166
Finally, export your ```config``` object, so that you can reference it within the ```app.js``` file.
@@ -172,50 +174,49 @@ Finally, export your ```config``` object, so that you can reference it within th
172
174
module.exports = config;
173
175
174
176
## <aid="Connect"></a> Step 4: Connect to an Azure Cosmos DB account
177
+
175
178
Open your empty ```app.js``` file in the text editor. Copy and paste the code below to import the ```documentdb``` module and your newly created ```config``` module.
176
179
177
180
// ADD THIS PART TO YOUR CODE
178
181
"use strict";
179
182
180
183
var documentClient = require("documentdb").DocumentClient;
Copy and paste the code to use the previously saved ```config.endpoint``` and ```config.primaryKey``` to create a new DocumentClient.
185
188
186
189
var config = require("./config");
187
-
var url = require('url');
188
190
189
191
// ADD THIS PART TO YOUR CODE
190
192
var client = new documentClient(config.endpoint, { "masterKey": config.primaryKey });
191
193
192
194
Now that you have the code to initialize the Azure Cosmos DB client, let's take a look at working with Azure Cosmos DB resources.
193
195
194
196
## Step 5: Create a Node database
195
-
Copy and paste the code below to set the HTTP status for Not Found, the database url, and the collection url. These urls are how the Azure Cosmos DB client will find the right database and collection.
197
+
198
+
Copy and paste the code below to set the HTTP status for Not Found, the database id, and the collection id. These ids are how the Azure Cosmos DB client will find the right database and collection.
196
199
197
200
var client = new documentClient(config.endpoint, { "masterKey": config.primaryKey });
198
201
199
202
// ADD THIS PART TO YOUR CODE
200
203
var HttpStatusCodes = { NOTFOUND: 404 };
201
-
var databaseUrl = `dbs/${config.database.id}`;
202
-
var collectionUrl = `${databaseUrl}/colls/${config.collection.id}`;
204
+
var databaseId = config.database.id;
205
+
var collectionId = config.collection.id;
203
206
204
207
A [database](sql-api-resources.md#databases) can be created by using the [createDatabase](https://azure.github.io/azure-documentdb-node/DocumentClient.html) function of the **DocumentClient** class. A database is the logical container of document storage partitioned across collections.
205
208
206
-
Copy and paste the **getDatabase** function for creating your new database in the app.js file with the ```id``` specified in the ```config``` object. The function will check if the database with the same ```FamilyRegistry``` id does not already exist. If it does exist, we'll return that database instead of creating a new one.
207
-
208
-
var collectionUrl = `${databaseUrl}/colls/${config.collection.id}`;
209
+
Copy and paste the **getDatabase** function for creating your new database in the app.js file with the ```databaseId``` specified from the ```config``` object. The function will check if the database with the same ```FamilyRegistry``` id does not already exist. If it does exist, we'll return that database instead of creating a new one.
@@ -227,7 +228,7 @@ Copy and paste the **getDatabase** function for creating your new database in th
227
228
}
228
229
});
229
230
});
230
-
}
231
+
};
231
232
232
233
Copy and paste the code below where you set the **getDatabase** function to add the helper function **exit** that will print the exit message and the call to **getDatabase** function.
233
234
@@ -245,7 +246,7 @@ Copy and paste the code below where you set the **getDatabase** function to add
@@ -256,31 +257,31 @@ In your terminal, locate your ```app.js``` file and run the command: ```node app
256
257
Congratulations! You have successfully created an Azure Cosmos DB database.
257
258
258
259
## <aid="CreateColl"></a>Step 6: Create a collection
260
+
259
261
> [!WARNING]
260
262
> **createCollection** will create a new collection, which has pricing implications. For more details, please visit our [pricing page](https://azure.microsoft.com/pricing/details/cosmos-db/).
261
-
>
262
-
>
263
263
264
264
A [collection](sql-api-resources.md#collections) can be created by using the [createCollection](https://azure.github.io/azure-documentdb-node/DocumentClient.html) function of the **DocumentClient** class. A collection is a container of JSON documents and associated JavaScript application logic.
265
265
266
-
Copy and paste the **getCollection** function underneath the **getDatabase** function in the app.js file to create your new collection with the ```id``` specified in the ```config``` object. Again, we'll check to make sure a collection with the same ```FamilyCollection``` id does not already exist. If it does exist, we'll return that collection instead of creating a new one.
266
+
Copy and paste the **getCollection** function underneath the **getDatabase** function in the app.js file to create your new collection with the ```collectionId``` specified from the ```config``` object. Again, we'll check to make sure a collection with the same ```FamilyCollection``` id does not already exist. If it does exist, we'll return that collection instead of creating a new one.
@@ -292,7 +293,7 @@ Copy and paste the **getCollection** function underneath the **getDatabase** fun
292
293
}
293
294
});
294
295
});
295
-
}
296
+
};
296
297
297
298
Copy and paste the code below the call to **getDatabase** to execute the **getCollection** function.
298
299
@@ -310,6 +311,7 @@ In your terminal, locate your ```app.js``` file and run the command: ```node app
310
311
Congratulations! You have successfully created an Azure Cosmos DB collection.
311
312
312
313
## <aid="CreateDoc"></a>Step 7: Create a document
314
+
313
315
A [document](sql-api-resources.md#documents) can be created by using the [createDocument](https://azure.github.io/azure-documentdb-node/DocumentClient.html) function of the **DocumentClient** class. Documents are user defined (arbitrary) JSON content. You can now insert a document into Azure Cosmos DB.
314
316
315
317
Copy and paste the **getFamilyDocument** function underneath the **getCollection** function for creating the documents containing the JSON data saved in the ```config``` object. Again, we'll check to make sure a document with the same id does not already exist.
@@ -319,17 +321,17 @@ Copy and paste the **getFamilyDocument** function underneath the **getCollection
319
321
}
320
322
});
321
323
});
322
-
}
324
+
};
323
325
324
326
// ADD THIS PART TO YOUR CODE
325
327
function getFamilyDocument(document) {
326
-
let documentUrl = `${collectionUrl}/docs/${document.id}`;
@@ -373,12 +375,12 @@ Copy and paste the **queryCollection** function underneath the **getFamilyDocume
373
375
}
374
376
});
375
377
});
376
-
}
378
+
};
377
379
378
380
// ADD THIS PART TO YOUR CODE
379
381
function queryCollection() {
380
-
console.log(`Querying collection through index:\n${config.collection.id}`);
381
-
382
+
console.log(`Querying collection through index:\n${collectionId}`);
383
+
let collectionUrl = uriFactory.createDocumentCollectionUri(databaseId, collectionId);
382
384
return new Promise((resolve, reject) => {
383
385
client.queryDocuments(
384
386
collectionUrl,
@@ -397,7 +399,6 @@ Copy and paste the **queryCollection** function underneath the **getFamilyDocume
397
399
});
398
400
};
399
401
400
-
401
402
The following diagram illustrates how the Azure Cosmos DB SQL query syntax is called against the collection you created.
402
403
403
404

@@ -431,14 +432,13 @@ Copy and paste the **replaceFamilyDocument** function underneath the **queryColl
431
432
}
432
433
});
433
434
});
434
-
}
435
+
};
435
436
436
437
// ADD THIS PART TO YOUR CODE
437
438
function replaceFamilyDocument(document) {
438
-
let documentUrl = `${collectionUrl}/docs/${document.id}`;
@@ -512,6 +512,7 @@ In your terminal, locate your ```app.js``` file and run the command: ```node app
512
512
Congratulations! You have successfully deleted an Azure Cosmos DB document.
513
513
514
514
## <aid="DeleteDatabase"></a>Step 11: Delete the Node database
515
+
515
516
Deleting the created database will remove the database and all children resources (collections, documents, etc.).
516
517
517
518
Copy and paste the **cleanup** function underneath the **deleteFamilyDocument** function to remove the database and all the children resources.
@@ -525,15 +526,15 @@ Copy and paste the **cleanup** function underneath the **deleteFamilyDocument**
525
526
526
527
// ADD THIS PART TO YOUR CODE
527
528
function cleanup() {
528
-
console.log(`Cleaning up by deleting database ${config.database.id}`);
529
-
529
+
console.log(`Cleaning up by deleting database ${databaseId}`);
530
+
let databaseUrl = uriFactory.createDatabaseUri(databaseId);
530
531
return new Promise((resolve, reject) => {
531
532
client.deleteDatabase(databaseUrl, (err) => {
532
533
if (err) reject(err)
533
534
else resolve(null);
534
535
});
535
536
});
536
-
}
537
+
};
537
538
538
539
Copy and paste the code below the call to **deleteFamilyDocument** to execute the **cleanup** function.
539
540
@@ -547,6 +548,7 @@ Copy and paste the code below the call to **deleteFamilyDocument** to execute th
547
548
.catch((error) => { exit(`Completed with error ${JSON.stringify(error)}`) });
548
549
549
550
## <aid="Run"></a>Step 12: Run your Node.js application all together!
551
+
550
552
Altogether, the sequence for calling your functions should look like this:
551
553
552
554
getDatabase()
@@ -598,6 +600,7 @@ You should see the output of your get started app. The output should match the e
598
600
Congratulations! You've created you've completed the Node.js tutorial and have your first Azure Cosmos DB console application!
599
601
600
602
## <aid="GetSolution"></a>Get the complete Node.js tutorial solution
603
+
601
604
If you didn't have time to complete the steps in this tutorial, or just want to download the code, you can get it from [GitHub](https://github.com/Azure-Samples/documentdb-node-getting-started).
602
605
603
606
To run the GetStarted solution that contains all the samples in this article, you will need the following:
Copy file name to clipboardExpand all lines: articles/event-hubs/event-hubs-availability-and-consistency.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ ms.author: sethm
23
23
## Overview
24
24
Azure Event Hubs uses a [partitioning model](event-hubs-features.md#partitions) to improve availability and parallelization within a single event hub. For example, if an event hub has four partitions, and one of those partitions is moved from one server to another in a load balancing operation, you can still send and receive from three other partitions. Additionally, having more partitions enables you to have more concurrent readers processing your data, improving your aggregate throughput. Understanding the implications of partitioning and ordering in a distributed system is a critical aspect of solution design.
25
25
26
-
To help explain the trade-off between ordering and availability, see the [CAP theorem](https://en.wikipedia.org/wiki/CAP_theorem), also known as Brewer's theorem. This theorem discusses the choice between consistency, availability, and partition tolerance.
26
+
To help explain the trade-off between ordering and availability, see the [CAP theorem](https://en.wikipedia.org/wiki/CAP_theorem), also known as Brewer's theorem. This theorem discusses the choice between consistency, availability, and partition tolerance. It states that for the systems partitioned by network there is always tradeoff between consistency and availability.
27
27
28
28
Brewer's theorem defines consistency and availability as follows:
29
29
* Partition tolerance: the ability of a data processing system to continue processing data even if a partition failure occurs.
0 commit comments