0:00
Hi everyone, welcome back to C Sharp Corner Live Show. I'm your host, Evan Simon, and we are back
0:12
with another episode of C Sharp Corner MMP Show, a show dedicated to the community leaders who
0:18
spend their time contributing to the community. They do this by writing articles, going to
0:25
different events, sharing their knowledge. It may be through forums and all that stuff
0:28
And if you are someone who is joining us for the very first time, we do this C Sharp Corner MVP show every Wednesday at 7.30 p.m. Indian Time Zone and 9 a.m. Eastern Time Zone
0:41
Earlier we did at 10 a.m. Eastern Time Zone, but now this summertime has changed something
0:46
So we do it at 9 a.m. Eastern and same time 7.30 p.m. Wednesdays
0:51
and the next show that we do is on every Thursday. We do this Ask Me Anything show
0:57
that is scheduled on 8.30 p.m. IST and 8.00 p.m. Eastern. We do other live shows that are about leadership
1:05
and growth mindset that's hosted by Mahesh. We do it on Fridays
1:09
And if you are someone who wants to learn about this. Dotted world, then we do this Rock in the Code world
1:14
with Dot and Dave's every Saturday, 10 a.m. PST. A really exciting show
1:19
where David often comes with this exciting music and all that stuff and brings very senior guys from the Microsoft ecosystem
1:26
So that's it with the online show that we do. Apart from this, we also do this Azure AI show
1:32
We also do this e-book launches. We do the humongous virtual conferences
1:38
We recently did global startup virtual conference and before that we did the Dortmund virtual conference
1:44
that was for two days, almost like 18 to 20 speakers, really reaching almost like 30,000 audiences
1:50
So if you are someone who is joining for the first time, just visit csharpcorner.com
1:55
and on the very homepage itself, you will find a section that says upcoming events
2:00
and there you can see updated. And a little peekaboo news that you should be expecting many more updates
2:06
into the feed of C Sharp Corner Live as 2021 should be very exciting
2:11
and we are very much committed on building a product out of the C Sharp Corner Live
2:15
So stay tuned for that. All right, so let's move to our show
2:20
Today's guest is someone very special. He's been a community contributor for a very long time
2:27
He is someone who is known to go ahead and write many articles
2:31
You can often find him even speaking in this virtual event. He's a frequent fire for this annual conference
2:39
that we did here in India. He's loved by everyone. He is Devasish Shah, who is a certified Microsoft trainer
2:45
He's a C-sharp owner MVP, minded he's six times. He's working as a lead engineer with V5 Soft Private Limited, Pune
2:54
and has over 11 plus years of experience in the IT industry. He's always been a great fan of Microsoft technologies
3:01
and we definitely know that as he has experience working ASP.NET, MVC, C-sharp, ASP.NET Core, Azure, SQL Server
3:09
and also he's kind of full stack developer as he works on React, JS, Angular, NoSQL
3:15
DiraBus, MongoDB, Cosmos, DiraBus, oh my goodness, what not. So today's show is going to be really exciting
3:20
We have an amazing person joining us today. DiraBus is joining us all the way from Calcutta, West Wing
3:27
I don't know, I need to ask him, but let's go and welcome him. Hi, Kishan
4:07
So, Devsiz, I'm good. Thank you, thank you so much. Where you are joining us today
4:12
I really fumbled whether you are joining us from Calcutta or West Bengal
4:16
Yeah, I'm so excited. Currently, I'm joining us from Calcutta. You're joining us from Calcutta
4:21
That's a beautiful city. How has your city been doing all through this pandemic
4:25
I know you have joining us, you often join us for these Goachiller conferences
4:29
But it looks like the lockdown is over and things are getting back to normal
4:33
How's things at your place? Yeah, this is the same. Lockdown is over and all the activities are going to start moving
4:42
And right now, transportation and other services also start servicing. So, hopefully within this month, the situation will be quite normal in the lockdown
4:55
Yeah, that's good. Things are getting better now. But it looks like there's a third wave coming
5:00
So we should be like, now we don't have lockdown, so we have to be very much safe from our end too
5:07
So talking about this MVP show, Debra Cesar, you have been a C Sharp Corner MVP for almost like six times, right
5:14
That's really, you have been very consistent looks like. Let's go and talk about how you first came to know about C Sharp Corner
5:21
When was the very first time you heard C Sharp Corner and thought of becoming an MVP for that
5:26
Yeah, actually I have not started writing in SysApp Corner for the MVP award
5:33
Actually in 2013, one of our previous company, I am working on V5 Soft and previously I am
5:43
working on Gamma Info Distance as a lead engineer. So there actually we are, that previous company is also a product company where we are actually
5:52
developing a product and that product is developed in the earlier versions of ASP
5:57
That is ASP.8 3.5 and we are planning to migrate the entire product in a latest technology
6:04
that is with the latest technology like MVC or Angular with OSPI like that
6:09
So this is the plan talking about the 2030. So at that time most of the seniors in our company
6:17
or most of the persons don't know about the MVC architecture. So company decided to
6:22
organized some technical training and they called one of the technical trainers
6:27
that's the suitcase mahalla from the mumbai and he came to calcutta for one week and he was
6:33
on technical training and during this training sessions we have a good relationship with the
6:39
suitcase i have a good relationship so bind up with the suitcase and suitcase actually inspired
6:44
me to start writing and share knowledge and at that time i am also thinking that good better because
6:51
when we share the knowledge with someone and that also helped me to improve myself also
6:58
so in this way i started writing in the c sub corner and then after one year i got an mvp award
7:06
so it basically is the one type of surprising me that for the first for the first year i have not
7:11
regular contributor i contributed one or two articles in a month or maybe in two months i
7:19
I have written articles of blog and they have started writing in regular basis and now it a one of the you can say it a one I have an one addictive person that I have to write some articles or something in a week otherwise I feel that I have not done something something
7:37
is not done by me in this week and I am missing something so now the writing is yeah writing is
7:43
been done with a daily activities one of the daily activities of the day after seven years of writing
7:50
yeah look I'm looking at your profile you joined in the year 2011
7:55
and your articles have been read more than close to 16 million times
8:01
I just cannot believe that number I mean your articles have been 16 million
8:05
times definitely this is humongous and with respect to that when I look at the number of articles
8:11
that you have written it is close to 156 with 19s being featured
8:17
so definitely people out there really love your content and you also contribute through forums, blogs, ebooks and that's great
8:26
And it looks like you are also a moderator for C Sharp Corner, one of the technologies
8:31
Who is a moderator at C Sharp Corner? Yeah, actually, moderator means, as a moderator, I have to follow the other articles in this
8:43
piece or like that. have to guide them what will be the better approach for writing articles or how one article
8:50
can be modified so that readers can be benefited better. Because our main purpose is not to write articles to advertise myself, but for writing articles
9:00
to share the knowledge to other readers so that the reader can learn something from the
9:06
articles and use that knowledge in their own personal work ethic or work experience
9:12
So this is the role for the monitor, so that what a new writer, so guide them to how to
9:18
write or take if there is any changes or something. So these are the guidelines you have to follow for the new writer
9:29
So definitely looks like you are spending a lot of time in the community, but not just
9:32
writing articles and doing events. You also help other people write better content and make sure the content is heard
9:39
So coming to the, we just don't talk in this show. We also do some demos
9:46
We also learn because you guys are IT professionals. In today's session, Devos, you say we're going to talk about Cosmos DB
9:55
It's really interesting, right? NoSQL database, people related with MongoDB. How, and I think you have worked both on MongoDB and this Cosmos DB, right
10:08
So let me quickly go ahead and ask, what do you prefer most? Having said that, I think MongoDB
10:15
at least for 4 gigs or 20 gigs, they give it for free, right? I'm not..
10:20
Yeah, MongoDB is actually for the enterprise community edition, it's gonna be free. So we can use the community edition
10:27
and also we can deploy the community edition for a small scale of client. But for MongoDB
10:33
enterprise editions we have to pay the license and in case of Cosmos DB since it is hosted in
10:38
the Azure so everything is a pay as you go yeah so what what what what is what does your clients
10:45
and what does your team prefer i mean you have both MongoDB and Cosmos DB what is what is your
10:51
first preference and your team yeah if the client wants to host the applications in the cloud
10:59
environment then obviously azure customers will be the better approach because in that case
11:05
maintenance is not a headache of the art because it's only maintained by the microsoft and everything
11:11
and also we can maintain to backup redundancy change your use there in everything is mentioned
11:18
by the azure infrastructure but if clients want to deploy the applications in their own servers
11:26
And if you have a server, if you have a server, if the client has their own server and they want to deploy your services in their own server, then Mongo can be a better option because in that time, for that purpose, they don't need to host the Mongo server or Azure server
11:40
They can also work on the internet system. They don't need to do the internet connectivity
11:46
Yes, so definitely depends upon clients. so IG said if you want to go back, yeah it's perfect. I think it's time we go and get started
11:55
and have a look at the amazing content and demos that you have today for everyone. I have your
12:00
screen you can the moment you move to your other screen I'll bring it to the live stream because
12:05
right now I can see myself. Perfect I have your presentation it says Cosmos DB Server Objects and
12:12
and next 335 methods are yours. Yeah, thank you Siddur. So, hi everybody
12:19
Today we will discuss about the Cosmos DB server object. So in this demo, we will define the Cosmos DB database
12:26
and then communicate the Cosmos DB database with the help of the sp.net NPC application
12:33
And then we insert or operate the cloud operations using the server of this like
12:39
sort for your trigger function, et cetera. So before going to the practical demo
12:45
we will discuss some basic cool concepts of the Cusmos DB. So I'm Devashit Shah, I'm a Microsoft Certified Trainer and Cusup of Curner
12:56
and also working as a post-struct developer in Cusmos DB. So today we are discussing about the server-side objects in Cusmos DB
13:06
and also the overview of server-side objects. What are the benefits of using server-side objects
13:38
Azure Corpus will be accounted in Azure portal. It basically creates the database and within the database there is a collection which basically is the container of the records and every collection contains a document which basically represents a single record
13:54
So we can say that document is basically the representative of row and collection is the alternative of a terrier in the concept of the RDV system
14:05
And also since in Curfus DB every document record has a fixed site limit
14:12
So if the document size has been more than 2 MB then it will be treated as attachment
14:17
and stored in the block service. So just like our digital system, every day a customer will have the user account or user
14:25
access and also it can provide a different potential to the user as per the accessibility
14:30
point of view. And against the collections, we can create server side objects like store procedure
14:37
trigger and user defined functions. These three, store procedure, trigger and user defined functions, are basically known
14:43
as the server side objects. So the main concept of server side objects is logic as a theory of the collection
14:51
So we can if we have a collection we have two logic which is the two have their own logic then we can use the server side objects to implement that logic This server side object is basically implemented or using by the JavaScript functions
15:07
So in case of user defined functions, we have calculations without side effects
15:13
of x on a single document. So user defined functions basically calculate any particular value without any effect in the document
15:21
So when we define a document, user defined function it basically does not affect the original document it simply
15:30
pick up the value from the document and perform some mathematical operations or some logical
15:36
operations and according to that return it so it's called from the utf names so normally for the
15:43
name system we are using the utf names for defining a user defined function in case of
15:49
So, as a short procedure, it basically operates on a group of documents in a collection
15:54
So, short procedure is always used for that, for documents. Short procedure is mainly used for the inserting record to or some validation implement systems
16:03
or value check or calcuring some value cycles. And for Trigger, as we know, if we have an idea about the ad-in-view system, so we know
16:12
what the path process is in Trigger. so trigger is basically used for data validation or transformations on inside of data checkments
16:20
in costum tv there are two types of trigger one is the free trigger and the post trigger critically
16:25
difficultly executed before the insertion of the data record and the post trigger is
16:29
executed after inserting the data in the and we cannot execute trigger automatically we need to
17:05
Also, we can share the logic between different clients or different databases
17:10
Also, encapsulation logic provides a structural layer of our data and the security of data
17:16
And also, the server-side object of the customer will provide the atomic transaction performance
17:22
like bulk operations, pre-compensation, and technology. So, in customer-based, when we perform any server-side operations, we have the active
18:44
So, this is my Azure portal account. I have already created a copy of the account for that
18:58
So, when we create a database, we can create a database. And in that database, we can create a server site option
19:08
So, we can click on a new database, and from there, we can provide a database name
19:41
and another for the API or MVC container. So for that purpose I have created one model
19:50
class called products. So this is the model class I have already created and these properties I have
19:56
already added in the product class and also some use complement validation part so for the
20:03
error method for so that it's going to be the error method for now in the app setting there is
20:10
a app setting complete of injection i have created a connection string object which contains four
20:16
properties one is the custom gb account c another is the connection screen another database name
20:24
so custom gb account and connection c can be obtained from the azure quota so when i created
20:30
as their custom with account then i go to the key section from there i can copy and copy this
20:39
correct screen ui copy key and the primary key and paste in this section and here the database
20:46
name means if the database which will be navigated for this activity will be used as a
20:51
control we can change the name as a say product and the container name will be the say that the product so this is the database name and i think
21:05
that container name the container name means basically is the collector's name or the table name
21:11
so when we run this application it will basically check this azure account
21:16
custom to the account and say either this product db database is created or not if this product db
21:21
database is not created then it will create the product db database uh if database already
21:26
is mentioned it will keep that straight so this is the code has been written in the
21:34
startup part this is the in play with the custom to the client part which i have written that it
21:40
will receive the database name can be done in the custom to the account and it includes a
22:06
also for this project we need to install some new bed packages which i have already installed here
22:55
So, at the point, it will be running in the application. It basically loads the Home page or the Porta list page in the UI part
23:08
And at that time, it will check that console.com and either that particular database exists
23:14
or not, if it does not exist, it will automatically create the database
24:16
So now the product DB has been already created and also within the product DB the product
24:35
collections of container also and in our project it is already loaded the whole page of the
24:44
our applications that is the product to ensure so at the time of installation loading it will check
24:51
that the data customers to be according to the database or not if there is no database so it
24:56
will create the product to be and within the product to create the product so when after we
25:46
i just simply refresh the data explorer and click on item so when you click on the items it will show
25:54
out that there will be the one record i've been inserted so let's select the record there it will
26:00
display media uh the cost which i have inserted so the photo site is one name will be a function
26:07
so what these are the screen values which i have given from the u icon if i want to add another
27:23
container is the database instance or the supposed to be instance and then we need to perform
27:30
call the query item action method and then pass the item or object which needs to be added
27:37
Similarly we can call the update method or delete method or other predefined method which we are
27:44
already defining the container plus so we can directly use it. So this is the
29:58
Now we have to move. the record by using the store procedure. So for using the store procedure, inserting the
30:07
new record using the store procedure, we need to make some changes in our add product
33:00
So this is the example of the trigger. Also you can define the trigger answer in the same way
33:07
So go to the product field and click on the new trigger
33:12
Here for creating the trigger, first provide the trigger name and then we need to provide
33:18
what is the trigger type, it's a trigger or post trigger and also for which operation this trigger will be added
33:53
there is a quantity which I have already mentioned in my UI part
33:58
There is a quantity and there is a price. So these two fields I have already mentioned in my UI
34:06
So now the trigger will restrict these two values and create a stock price for the product
34:13
and sort the value of stock price in a total stock price which is not in my UI part
34:19
So for that purpose I need to expose my stoppriced property. Yeah, put out stoppriced property I have already been exposed
34:29
So now save the trigger to execute it for the trigger. And back to the source for Visual Studio, we need to change the data context code for the trigger environment
34:48
So this code will not work for the trigger because it is for the execution of our portfolio
34:56
But trigger we need to call this. So container.createItem is a thing
35:01
So this is the same thing here which we used earlier. But here we see this is the item and then we find the partition script, this is the same
35:11
If we want to using the trigger, then we will use this options to define the trigger
38:57
But now for retrieving this for the UDA function we need to return the second query where we need to include the UDA function which may set the name just like our extreme query
39:12
These are the query name which we are going to return from the requiring also we are using reminder or user-dependent function name as a column and passing the value function
41:37
I'm sorry, I was muted. You thought there's something wrong with you, right? Yeah
41:52
So that is, I mean, you just created the crowd, we saw different functionalities
41:56
We have some questions coming from our internal channels and one of our personal cases that does Azure Cosmos DB support time series ysis
42:09
Yeah, if we're using the time series, that is the function of the Azure portal, not the Cosmos DB
42:17
So we can implement that. Perfect. That sounds great. So it comes, you mean, you need to say like it's not just very specific to Azure Cosmos DB
42:27
if you are doing in the Azure, it comes out of the box and maybe not just time series ysis
42:33
there might be many more that should help you maybe monitor your servers and to make sure that
42:37
it's all good. That comes out of the box, right? Yeah, yeah. That is also available in the standard
42:42
features of the Azure portal. So we can take those parts in the Azure portal
42:50
Perfect, perfect. So there's one more question coming in. I think he asked Mukesh
42:56
Shari Mukesh asked it is how can a bulk insert document into Cosmos DB I don't
43:03
understand it but I just yeah actually for bulk insert there are two two
43:07
approach one is we can create some utility tools by using them it's our
43:12
awesome any other language and then insert the record because yeah we also
43:17
actually performing the same time because I have using one by one record but also
43:21
can i can insert the bulk of 100 records or dash of 100 records to the uh c sub driver or another
43:29
option is from the portal we can insert the record because in the azure portal when we go to the
43:35
detect to this portal we can in bulk upload the data uh in there you have these options for upload
43:44
items so here we can upload a JSON file which contains a list of JSON objects and that can be uploaded
43:54
But for manual upload we need to JSON format data in the JSON file
43:59
What would be your preference, Devase, doing it from the code perspective, from your IDE, from your ecosystem or going to the Azure portal
44:06
What would you like to do at the first place? if it is a one-time job then it would be the better for the using the azure photo
44:13
or that part of it is not that something to develop any program but if it's a recurring job
44:18
or a daily basis job then i think it will be better for uh preparing the uh tools some
44:25
because always user is that's not understand about the json format so there is a chances to
44:32
some mistakes in the json format so it would better to prepare some utility which can read
44:37
from the excel file and the non-technical person is much more familiar with the excel format
44:48
and with all this low code no code coming in the hr people moving into this and this development
44:53
right it's getting a little more it's better to stick to what most of the people can understand
44:58
a quick question out of the box is there any storage limit for i know it is cloud but is
45:04
Is there anything like storage limit? With my example, we have like, okay, these many are the columns
45:11
These many are the rows and columns, you can do it. Right
45:15
So is there anything with this Azure Cosmos DB? No, actually there is no storage limit, but there is one of the throughput functions
45:22
Because the charges in the Cosmos DB is basically calculated not about the storage, but about
45:28
the throughput, major result throughput. So, if the throughput is high then the charges will be high
45:39
Suppose if I have changes the value to 1000 then it will be the increase of daily rate
45:46
So right now if I have to use the 1000 throughput then it will be the charge to $1.92 per day
45:52
If I put at 1000 daily, it will be the double. So, the major changes are viewed daily and also there is a space limit, 5 people are supposed to be using the
46:03
So, the HTTP of state, but there is no space limit because if the data size has been increased, it automatically
46:09
It's already been increased. Perfect, perfectly, definitely makes sense. So, you know, what we have actually seen is when we used to work and
46:18
and people still work a lot more with this SQL thing. And it is almost said that you need to normalize your data
46:25
There should be no redundancy. But this Azure Cosmos DB, people say that if you want to go ahead and duplicate the data
46:32
it's totally okay. And I've seen people doing it a lot, right? So how do you think that it does differ from
46:40
you don't, I think, let me ask you, do you normalize your data when you go ahead
46:44
and start working with Cosmos DB? Because with mySkili do a lot of stuff, you are told to do it
46:50
Is it the same with Cosmos DB? Yeah, actually, Cosmos DB is not required to normalize because it supports the MongoDB
46:58
architecture with no SQL format. So we can use the normalize pattern in the Cosmos DB also
47:06
So this is one of the major benefits because we can, for that purpose, we can do much more
47:12
time in the database part. In our DB system we have to define a data schema, table schema, data structure everything
47:19
But in terms of Cosmos DB, we also need to think about it because it automatically shows
47:26
the data and its an object. So it can accept any structure or any type of data
47:31
Yeah and I see many people moving into now this Cosmos DB because I think storage is
47:38
not a problem. Even the phone that I have, it may have one TB of storage
47:44
And I think my SQL was built somewhere around in 1970s, where even a GB would cost $100 to $100
47:50
That's why we had so many normalizers. And you said, no, don't duplicate your data
47:54
It's going to slow it. But I think now the storage is very cheap
47:58
And if you're just going to duplicate it, it's OK. It's fine. in my application and just execute that
48:34
Then automatically, whatever the new records have been inserted, it automatically takes care
48:37
by the database itself. But for artificial intelligence, we need to implement that
48:43
skip changes or other LSPR also. Yeah. A lot goes in the, when you
48:51
just need to go and even change a type of a column, maybe in the sequel
48:56
you have to do a lot of stuff in the in Cosmos, it it looks like a piece of a cake. Let's take one more question that is coming is, you talked about
49:05
containers, is it possible to switch from container level throughput provisioning to database level
49:11
throughput or vice versa? Yeah, it's possible. Okay, perfect. Basically database level means
49:19
actually there is a when we create a database there is a provision that
49:22
and how we will be providing the throughput. But in database level throughput, basically we are not using it because in that case
49:30
performance will be required. So, we will implement the database level throughput
49:35
But, yeah, database level throughput can be possible during the configuration of the data
49:41
And also, vice versa, it's possible, right? Yeah. Perfect. Perfectly. And you give all this demo that you showed, David
49:48
I know this is definitely going to be there on C Sharp on a platform. someone who is working in a team or maybe wants to go ahead and get started with Cosmos DB is there
49:56
i know the documentation is great but is there any readymade examples or a github repository
50:02
you may have or the the azure ecosystem may have they can go ahead and check it out
50:08
actually i have already posted this in my article all right so let me check if we have any more questions coming in
50:45
okay can i have okay i think that that's all that we have but uh yeah i have already
50:56
can you share that link what is that article yeah okay i got it implement stored procedure right
51:02
udf's i got it yeah copying i just copied it uh i'm gonna put it into the chat so that people can
51:10
go ahead and even read it and just copy it yeah perfect that looks an amazing article my goodness 100 what is that 142 000
51:32
And your articles are so detailed. I mean, you cover the entire ecosystem
51:38
You have code, and you go in and explain every single line of code. Then there's an hierarchy
51:43
Then there's a demo coming in. My goodness. That's an entire, very big girl
51:49
See, it looks like your articles have read many times, right? And people just love your article
51:53
And those 15 million or 16 million readers, you're close to 16 million, and you're ranked at 11
52:01
Oh, my goodness. So that's great, Devisees. It was amazing having you at the show
52:09
Quick question, quick question that we'll ask you, apart from all this technical stuff, right
52:15
So when you're free, Devisees, what do you like to do apart from this tech thing
52:19
What's your hobby? What's your interest? Yeah, I have free time, except writing articles
52:24
or reading blogs, watching movies or different movies. I am also out of the water traveling or in new places but right now it is not possible
52:38
So only watching movies or listening to music. Are you not a fan of football
52:50
Don't tell me that. Yeah. Do you watch football? Yeah, definitely. We are always watching the football and cricket ball
53:01
So, I appreciate the Arsenal's target. So, we are busy for times
53:06
I remember Messi visited Calcutta some time back and also Mohan Bagan is very famous, right
53:12
Mohan Bagan is a very big team. I think they have played across countries across the globe
53:17
And even Atletico de Calcutta, they have been doing very nice on Indian Superlake
53:22
Superlake. So definitely Kalkara is something I love to watch. I've been
53:27
to Kalkara. Fortunately, I've done my studies over there. So that's fantastic
53:31
Kalkara is an amazing place. Thank you so much. Every time you come on to this
53:35
show, I really always love it. Thank you for inviting me on this show. Also, thank you for the caller and you too
53:40
for inviting me on this show. And we definitely look forward to meeting you in person. Definitely
53:46
we'll meet you in person. I'm not sure about the conference happening next
53:51
year too because things will be a little challenging here in Delhi. Things are getting a little bad. We'll see. Maybe we'll do a small tour or whatever
53:58
So thank you so much. Have a great day ahead and that's it. Thank you so much. See you soon