1 00:00:00,860 --> 00:00:03,520 So, this lesson is going to be 2 00:00:03,520 --> 00:00:05,470 a little bit different. 3 00:00:05,470 --> 00:00:07,960 And to fit in with that vein, 4 00:00:07,960 --> 00:00:10,630 I did a search for odd-looking pictures. 5 00:00:10,630 --> 00:00:12,980 And lo and behold, this is what came up. 6 00:00:12,980 --> 00:00:16,340 And I thought, "Yeah, that kind of fits the bill." 7 00:00:16,340 --> 00:00:18,220 (Brian chuckling) So that's what this lesson's going to be. 8 00:00:18,220 --> 00:00:20,270 It's going to be one of those oddball lessons 9 00:00:20,270 --> 00:00:23,310 that is listed as something that you need to know 10 00:00:23,310 --> 00:00:25,320 for the DP-203, 11 00:00:25,320 --> 00:00:27,340 but only just a little bit. 12 00:00:27,340 --> 00:00:28,760 Let me explain. 13 00:00:28,760 --> 00:00:32,490 So today we will be discussing how to upsert 14 00:00:32,490 --> 00:00:35,530 via output to Cosmos DB. 15 00:00:35,530 --> 00:00:36,970 And if you will remember, 16 00:00:36,970 --> 00:00:41,970 that upserting is just simply a way for us to update data 17 00:00:42,210 --> 00:00:43,550 if it already exists, 18 00:00:43,550 --> 00:00:47,970 or create new rows to data if it does not exist. 19 00:00:47,970 --> 00:00:51,280 Now, you'll note that we are now talking about Cosmos DB. 20 00:00:51,280 --> 00:00:52,437 And you might think to yourself, 21 00:00:52,437 --> 00:00:57,437 "Cosmos DB... that's not really in the DP-203, is it?" 22 00:00:57,740 --> 00:00:59,930 No. You would be correct. 23 00:00:59,930 --> 00:01:03,070 Cosmos DB is not actually in the DP-203. 24 00:01:03,070 --> 00:01:05,940 There's a separate exam just for Cosmos. 25 00:01:05,940 --> 00:01:07,400 With that being said, 26 00:01:07,400 --> 00:01:09,640 we are talking about Azure Stream Analytics 27 00:01:09,640 --> 00:01:12,090 and how we upsert into Cosmos DB, 28 00:01:12,090 --> 00:01:14,140 because it's a requirement. 29 00:01:14,140 --> 00:01:17,020 So we are going to talk about how we do that 30 00:01:17,020 --> 00:01:19,490 by setting our compatibility levels. 31 00:01:19,490 --> 00:01:20,350 And then finally, 32 00:01:20,350 --> 00:01:23,950 we're going to talk about what Cosmos DB is--sort of. 33 00:01:23,950 --> 00:01:25,850 I'm going to give you like a 30-second overview 34 00:01:25,850 --> 00:01:30,110 because, again, Cosmos DB is not on this exam. 35 00:01:30,110 --> 00:01:32,330 So don't think that you need to understand how it works 36 00:01:32,330 --> 00:01:33,920 because you really don't. 37 00:01:33,920 --> 00:01:37,530 Finally, we're going to take a minute to see this in action. 38 00:01:37,530 --> 00:01:40,290 With that, go ahead and jump in and get started. 39 00:01:40,290 --> 00:01:42,323 Upserting via Cosmos DB. 40 00:01:43,580 --> 00:01:47,570 So you can upsert databases from Stream Analytics 41 00:01:47,570 --> 00:01:51,350 only through Azure Cosmos DB currently. 42 00:01:51,350 --> 00:01:54,040 Now with that, you use JSON output 43 00:01:54,040 --> 00:01:56,960 in order to push that into Cosmos DB 44 00:01:56,960 --> 00:02:00,310 and then use your upserting capabilities. 45 00:02:00,310 --> 00:02:03,780 Now, most of the action actually happens 46 00:02:03,780 --> 00:02:05,720 on the Cosmos DB side. 47 00:02:05,720 --> 00:02:08,420 You just need to understand that you can do this. 48 00:02:08,420 --> 00:02:12,420 So from Cosmos DB, you would go in and create containers. 49 00:02:12,420 --> 00:02:15,120 You would also set your billing, performance, 50 00:02:15,120 --> 00:02:18,900 consistency levels, capacity, all that's set in Cosmos. 51 00:02:18,900 --> 00:02:20,340 And I'm not even going to talk about it 52 00:02:20,340 --> 00:02:22,750 because you really don't need to know what that is, 53 00:02:22,750 --> 00:02:24,520 because it's not on the exam. 54 00:02:24,520 --> 00:02:25,353 You just need to know 55 00:02:25,353 --> 00:02:27,880 that you can upsert databases from Stream Analytics 56 00:02:27,880 --> 00:02:31,133 only in Cosmos DB using JSON output. 57 00:02:32,120 --> 00:02:33,380 The next thing you need to do is 58 00:02:33,380 --> 00:02:36,320 you need to look at setting your compatibility level. 59 00:02:36,320 --> 00:02:39,110 Now, this is done in Azure Stream Analytics. 60 00:02:39,110 --> 00:02:41,430 And I'll show you how to do that in just a minute. 61 00:02:41,430 --> 00:02:44,500 But think of compatibility levels kind of like versions. 62 00:02:44,500 --> 00:02:47,100 So right now, we're run version 1.2. 63 00:02:47,100 --> 00:02:49,450 This is what we want to use for upserting. 64 00:02:49,450 --> 00:02:52,500 And then there's a couple of previous generations as well 65 00:02:52,500 --> 00:02:54,120 that has reduced capabilities, 66 00:02:54,120 --> 00:02:56,563 at least as far as upserting is concerned. 67 00:02:59,350 --> 00:03:01,970 So what is Cosmos DB? 68 00:03:01,970 --> 00:03:04,290 Well, it is a globally distributed-- 69 00:03:04,290 --> 00:03:07,360 and you'll hear globally like 15,000 times 70 00:03:07,360 --> 00:03:09,040 when you read about Cosmos DB-- 71 00:03:09,040 --> 00:03:11,900 but it's a globally distributed NoSQL database. 72 00:03:11,900 --> 00:03:14,860 It contains 5 different consistency levels. 73 00:03:14,860 --> 00:03:16,670 I did mention global, right? 74 00:03:16,670 --> 00:03:18,200 Seriously, you'll hear that a lot 75 00:03:18,200 --> 00:03:20,130 when you talk about Cosmos DB. 76 00:03:20,130 --> 00:03:21,290 It's also multi-model, 77 00:03:21,290 --> 00:03:23,150 which just means that there's a lot of different ways 78 00:03:23,150 --> 00:03:25,050 that you can present your data. 79 00:03:25,050 --> 00:03:27,780 So you can use SQL, or Cassandra, or MongoDB, 80 00:03:27,780 --> 00:03:29,320 or Gremlin, or Table. 81 00:03:29,320 --> 00:03:31,950 So there's quite a few options when you look at it. 82 00:03:31,950 --> 00:03:34,430 And it's got extremely high availability, 83 00:03:34,430 --> 00:03:35,800 again because it's designed 84 00:03:35,800 --> 00:03:38,220 for large-scale production environments. 85 00:03:38,220 --> 00:03:42,650 And so availability, global distribution, multi-model, 86 00:03:42,650 --> 00:03:44,450 all those things are very important. 87 00:03:46,720 --> 00:03:49,530 All right, with that, let's see it in action. 88 00:03:49,530 --> 00:03:50,740 I mean, sort of. 89 00:03:50,740 --> 00:03:52,580 So what I'm going to do is I'm going to go in 90 00:03:52,580 --> 00:03:54,110 and I'm going to show you 91 00:03:54,110 --> 00:03:57,550 what we need to do from the Azure-Stream-Analytics side. 92 00:03:57,550 --> 00:04:00,230 I am not going to dive into Cosmos DB. 93 00:04:00,230 --> 00:04:02,990 All right, with that, let's do it. 94 00:04:02,990 --> 00:04:06,390 So here we find ourselves in Azure Stream Analytics. 95 00:04:06,390 --> 00:04:10,670 We are simply going to scroll down to Compatibility level. 96 00:04:10,670 --> 00:04:14,400 Click, and that easy. 97 00:04:14,400 --> 00:04:15,810 We just go over here. 98 00:04:15,810 --> 00:04:18,970 We choose 1.2. And we would click on Save. 99 00:04:18,970 --> 00:04:20,090 That's all you need to do. 100 00:04:20,090 --> 00:04:22,200 Then you're set with the compatibility level. 101 00:04:22,200 --> 00:04:24,820 And again, just keep in mind that 102 00:04:24,820 --> 00:04:27,580 you would be setting everything else from Cosmos DB 103 00:04:27,580 --> 00:04:31,253 and you're pushing JSON through Azure Stream Analytics. 104 00:04:32,190 --> 00:04:33,630 So in review, 105 00:04:33,630 --> 00:04:36,750 CosmosDB JSON is required for upserts. 106 00:04:36,750 --> 00:04:38,550 Set your compatibility level for 1.2 107 00:04:40,030 --> 00:04:41,440 in Azure Stream Analytics. 108 00:04:41,440 --> 00:04:46,120 And Cosmos DB is a globally available NoSQL service 109 00:04:46,120 --> 00:04:48,570 that isn't on the DP-203. 110 00:04:48,570 --> 00:04:50,450 All right, that's it for this lesson. 111 00:04:50,450 --> 00:04:54,410 Let's jump back into a few more mainstream components. 112 00:04:54,410 --> 00:04:55,810 I'll see in the next lesson.