-
Notifications
You must be signed in to change notification settings - Fork 2
/
azure.html
1719 lines (1707 loc) · 77.6 KB
/
azure.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<title>CNC Cheet Sheet theme for developers</title>
<!-- Meta -->
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="" />
<meta name="author" content="" />
<link rel="shortcut icon" href="favicon.ico" />
<link
href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800"
rel="stylesheet"
type="text/css"
/>
<!-- FontAwesome JS -->
<script
defer
src="https://use.fontawesome.com/releases/v5.8.2/js/all.js"
integrity="sha384-DJ25uNYET2XCl5ZF++U8eNxPWqcKohUUBUpKGlNLMchM7q4Wjg2CUpjHLaL8yYPH"
crossorigin="anonymous"
></script>
<!-- Global CSS -->
<link
rel="stylesheet"
href="assets/plugins/bootstrap/css/bootstrap.min.css"
/>
<!-- Plugins CSS -->
<link rel="stylesheet" href="assets/plugins/prism/prism.css" />
<link rel="stylesheet" href="assets/plugins/elegant_font/css/style.css" />
<!-- Theme CSS -->
<link id="theme-style" rel="stylesheet" href="assets/css/styles.css" />
</head>
<body class="body-dark-blue">
<div class="page-wrapper">
<!-- ******Header****** -->
<header id="header" class="header">
<div class="container">
<div class="branding">
<h1 class="logo">
<a href="index.html">
<span aria-hidden="true" class="icon_documents_alt icon"></span>
<span class="text-highlight">CNC</span
><span class="text-bold">Cheet Sheet</span>
</a>
</h1>
</div>
<!--//branding-->
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="index.html">Home</a></li>
<li class="breadcrumb-item active">Azure</li>
</ol>
<div class="top-search-box">
<form
id="srch"
class="form-inline search-form justify-content-center"
action=""
method="get"
>
<input
id="data"
type="text"
placeholder="Enter search terms..."
value=""
class="form-control search-input"
/>
<button type="submit" class="btn search-btn" value="Search">
<i class="fas fa-search"></i>
</button>
</form>
</div>
</div>
<!--//container-->
</header>
<!--//header-->
<div class="doc-wrapper">
<div class="container">
<div id="doc-header" class="doc-header text-center">
<h1 class="doc-title">
<img alt="Azure-icon" src="azure.png" /> Azure Quick Start
</h1>
</div>
<!--//doc-header-->
<div class="doc-body row">
<div class="doc-content col-md-9 col-12 order-1">
<div class="content-inner">
<section id="download-section" class="doc-section">
<h2 class="section-title">Installation & Setup</h2>
<div class="section-block">
<p>
When working with a tool like Azure it is very important
to make a good friendship with its <b>documentation</b>
<a href="https://Azure.io/docs/home/">link</a> <br />
to setup Azure we will need two main components
</p>
<ul>
<li>kubectl</li>
<li>minikube</li>
<li>virtual box(optional)</li>
</ul>
<p>
if you have any problem or error during the setup you can
refer to google.....
</p>
<a
href="https://Azure.io/docs/tasks/tools/install-kubectl/#install-kubectl-on-linux"
class="btn btn-blue"
target="_blank"
><i class="fas fa-download"></i> Setup guide for Azure</a
>
</div>
</section>
<!--//doc-section-->
<section id="installation-section" class="doc-section">
<h2 class="section-title">Installation</h2>
<div id="step1" class="section-block">
<h3 class="block-title">Step One</h3>
<p>
First we need to install kubectl through which we will
manage Azure.<br />
if you are using linux just copy and paste these commands
one by one.
</p>
<div class="code-block">
<h6>Commands:</h6>
<p><code>sudo apt-get install curl</code></p>
<p>
<code
>curl -LO
https://storage.googleapis.com/Azure-release/release/`curl
-s
https://storage.googleapis.com/Azure-release/release/stable.txt`/bin/linux/amd64/kubectl</code
>
</p>
<p><code>chmod +x ./kubectl</code></p>
<p>
<code>sudo mv ./kubectl /usr/local/bin/kubectl</code>
</p>
<p>To test run below command</p>
<p><code>kubectl version --client</code></p>
</div>
<!--//code-block-->
</div>
<!--//section-block-->
<div id="step2" class="section-block">
<h3 class="block-title">Step Two</h3>
<p>
Now we will install minikube, when using minikube 8Gb RAM
is recommended.<br />
if you are using linux then just copy and paste these
commands one by one.
</p>
<div class="code-block">
<h6>Commands:</h6>
<p>
<code
>curl -Lo minikube
https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64</code
>
</p>
<p><code>chmod +x minikube</code></p>
<p><code>sudo mkdir -p /usr/local/bin/</code></p>
<p><code>sudo install minikube /usr/local/bin/</code></p>
</div>
<!--//code-block-->
</div>
<!--//section-block-->
<div id="step3" class="section-block">
<h3 class="block-title">Step Three</h3>
<p>
In this step we will install virtual box which is
<b>optional</b>, if you want to use virtual box then make
sure your machine supports virtualization <br />
To check that your system supports virtualization or not
run the command below <br />
<code>grep -E --color 'vmx|svm' /proc/cpuinfo</code>
if this command returns some output then you are good to
go else continue without install virtual box.
</p>
<div class="code-block">
<h6>Commands:</h6>
<p><code>sudo apt-get update</code></p>
<p><code>sudo apt-get upgrade</code></p>
<p>
<code
>wget -q
https://www.virtualbox.org/download/oracle_vbox_2016.asc
-O- | sudo apt-key add -</code
>
</p>
<p>
<code
>wget -q
https://www.virtualbox.org/download/oracle_vbox.asc
-O- | sudo apt-key add -</code
>
</p>
<p>
<code
>sudo add-apt-repository "deb
http://download.virtualbox.org/virtualbox/debian
xenial contrib"</code
>
</p>
<p><code>sudo apt-get update</code></p>
<p><code>sudo apt-get install virtualbox</code></p>
</div>
<!--//code-block-->
</div>
<!--//section-block-->
<div id="step4" class="section-block">
<h3 class="block-title">Step Four</h3>
<p>
Lets check that we installed all 3 or 2 main tools
correctly or not.<br />
Run the commands that is based on your criteria. <br />
if one fails because of any error use the command below
and then try next command.
<code>minikube delete</code>
</p>
<div class="code-block">
<h6>Commands:</h6>
<p><code>minikube start</code></p>
<p>above command will start minikube using virtual box</p>
<p><code>minikube start --driver=none</code></p>
<p>
if you have not installed virtual box then use the above
command, if it also not works the try the below command.
</p>
<p><code>minikube start --driver=docker</code></p>
<p>above command will start minikube using docker</p>
<p>
If none of the above command worked for you then try
adding <b>--force</b> flag to command <br />
example :
<code>minikube start --driver=docker --force</code>
</p>
</div>
<!--//code-block-->
<h3>If minikube Starts</h3>
<p>
If minikube starts then you can type the below command to
get its status
</p>
<p><code>minikube status</code></p>
<p>
this command will return result similler to <br />
host: Running kubelet: Running apiserver: Running
</p>
<p>Now its all set to us Azure :-)</p>
</div>
<!--//section-block-->
</section>
<!--//doc-section-->
<section id="RG" class="doc-section">
<h2 class="section-title">Resource Group (RG)</h2>
<div class="section-block">
<p>
<a
href="https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/manage-resource-groups-cli"
target="_blank"
>Link to official docs</a
><br />
it is like a container that can contain different azure
resources, we usr RG to deploy resource according to some
logical context
</p>
<h6>Important notes about RGs</h6>
<ul>
<li>
If you delete a resource group all the resources in that
RG will be deleted
</li>
</ul>
</div>
<!--//section-block-->
<div id="rg-using-cli" class="section-block">
<h5>RG using Azure cli</h5>
<div class="code-block">
<pre><code class="language-git">az group create \
--name "<name of rg>" \
--location "location or region>"</code></pre>
</div>
</div>
<!--//section-block-->
</section>
<!--//doc-section-->
<section id="VM" class="doc-section">
<h2 class="section-title">Virtual Machine (VM)</h2>
<div class="section-block">
<p>
<a
href="https://docs.microsoft.com/en-us/azure/virtual-machines/"
target="_blank"
>Link to official docs</a
><br />
it is a resource of Azure similer to a windows or linux
computer system. It is mostly used when an application
requires a custom configuration or you want full control
over the environment where your application is going to be
deployed.<br />Below is the
<b>minimum set of configuration</b> to deploy a vm
</p>
<h6>Important notes about VMs</h6>
<ul>
<li>vm is a resource</li>
<li>deployed in a resource group</li>
<li>vm size can be changed after deployment</li>
<li>steps : Rg->vm->vm ports->public ip</li>
</ul>
</div>
<!--//section-block-->
<div id="vm-using-cli" class="section-block">
<h5>VM using Azure cli</h5>
<p>you can mainly make 2 types of vms</p>
<ul>
<li>windows vm</li>
<li>Linux vm</li>
</ul>
<div class="code-block">
<h6>For Windows VM</h6>
<pre><code class="language-git">az vm create \
--resource-group "<name of rg>" \
--name "<name of vm>" \
--image "window" \
--admin-username "<windows admin user-name>" \
--admin-password "<windows admin password>"</code></pre>
<h6>For Linux VM</h6>
<pre><code class="language-git">az vm create \
--resource-group "<name of rg>" \
--name "<name of vm>" \
--image "Linux" \
--admin-username "<linux admin user-name>" \
--authentication-type "ssh" \
--ssh-key-value <path to .pub file></code></pre>
</div>
<!--//code-block-->
<p>
After deploying a vm you may want to access it using RDP
or ssh, for that you have to open the specific port on the
newly created vm
</p>
<div id="vm-open-port" class="code-block">
<h6>opening port</h6>
<pre><code class="language-git">az vm open-port \
--resource-group "<name of rg>" \
--name "<name of vm>" \
--port "3389 or 22"</code></pre>
</div>
<!--//code-block-->
<p>
for loging in the vm you might also need the
<b>public ip</b> of the vm for that you can use the
command below
</p>
<div id="vm-public-ip" class="code-block">
<h6>accessing public ip</h6>
<pre><code class="language-git">az vm list-ip-addresses \
--resource-group "<name of rg>" \
--name "<name of vm>" \
-output table</code></pre>
</div>
<!--//code-block-->
</div>
<!--//section-block-->
</section>
<!--//doc-section-->
<section id="ACR" class="doc-section">
<h2 class="section-title">Azure Container Registry (ACR)</h2>
<div class="section-block">
<p>
<a
href="https://docs.microsoft.com/en-us/azure/container-registry/"
target="_blank"
>Link to official docs</a
><br />
It isAzure resource used as a private container image
repository.
</p>
<h6>Important notes about VMs</h6>
<ul>
<li>ACR is a resource</li>
<li>deployed in a resource group</li>
<li>build, store & manage images</li>
<li>
steps : Rg->ACR->ACR login->push image or code to build
image
</li>
<li>
use <b>headless authentication</b> for intigrating with
other applications for automation
</li>
</ul>
<div id="acr-using-cli" class="section-block">
<h4>ACR using Azure cli</h4>
<div class="code-block">
<pre><code class="language-git">az acr create \
--resource-group "<name of rg>" \
--name "<name of ACR globally unique>" \
--sku "Basic, Standard or Premium"</code></pre>
<h5>Login to ACR</h5>
<pre><code class="language-git">az acr login --name "<name of ACR>"</code></pre>
</div>
<!--//code-block-->
<p>
After logging in you may want to <b>Push an Image</b> or
<b>Push the code</b> to build image usung ACR tasks
</p>
<h5 id="push-image-acr">Push image to ACR</h5>
<div class="code-block">
<h6>Get login server (URL or domain)</h6>
<pre><code class="language-git">az acr show \
--name "<name of ACR>" \
--query loginServer \
--output table</code></pre>
</div>
<!--//code-block-->
<div class="code-block">
<h6>Tag the image</h6>
<p>
you need to tag the image with login server to tell it
where to upload.
</p>
<pre><code class="language-git">docker tag <image id> <login server>/<image name>:<tag></code></pre>
</div>
<!--//code-block-->
<div class="code-block">
<h6>Push the image</h6>
<pre><code class="language-git">docker push <login server>/<image name>:<tag></code></pre>
</div>
<!--//code-block-->
<h5 id="push-code-acr">Push Code to ACR</h5>
<p>
push the code to build the image in ACR using ACR tasks
</p>
<div class="code-block">
<pre><code class="language-git">az acr build
--image "<name of future image>:"<tag>" \
--registry "<ACR name>" \
"<path to Dockerfile>"</code></pre>
</div>
<h5 id="acr-list-images">List images in ACR</h5>
<div class="code-block">
<pre><code class="language-git">az acr repository list --name "<name of ACR>" --output table</code></pre>
</div>
<!--//code-block-->
<div class="code-block">
<pre><code class="language-git">az acr repository show-tags list --name "<name of ACR>" --repository "<name of repository or image>" --output table</code></pre>
</div>
<!--//code-block-->
</div>
</div>
<!--//section-block-->
</section>
<!--//doc-section-->
<section id="ACI" class="doc-section">
<h2 class="section-title">Azure Container Instances (ACI)</h2>
<div class="section-block">
<p>
<a
href="https://docs.microsoft.com/en-us/azure/container-instances/"
target="_blank"
>Link to official docs</a
><br />
it is a resource that lets you run docker container
serverlessly(without managing base Os).Azure Container
Instances is a solution for any scenario that can operate
in isolated containers, without orchestration.
</p>
<h6>Important notes about ACI</h6>
<ul>
<li>ACR is a resource</li>
<li>serverless container platform</li>
<li>allows access applications via internet or vNet</li>
<li>supports both windows and linux containers</li>
<li>configuable resource size</li>
<li>can presist dataif needed using azure files</li>
<li>can be deployed in group</li>
<li>has restart policy</li>
<li>better for event driven architecture</li>
<li>steps: create container</li>
</ul>
</div>
</section>
<!--//section-block-->
<section id="app-service" class="doc-section">
<h2 class="section-title">Azure App Service</h2>
<div class="section-block">
<p>
<a
href="https://docs.microsoft.com/en-us/azure/app-service/"
target="_blank"
>Link to official docs</a
><br />
it is a resource that enables you to
<b>build and host web apps</b>, mobile back ends, and
RESTful APIs in the programming language of your choice
without managing infrastructure.<b
>Code to deploy comes from git or other systems</b
>
</p>
<h6>Important notes about App Service</h6>
<ul>
<li>App Service is a resource</li>
<li>web based hosting</li>
<li>supports both windows and linux apps</li>
<li>security, load balencing & automation</li>
<li>cost depends on <b>App Service Plan</b></li>
<li>steps: app service plan->create webapp</li>
</ul>
<p>There are two types of App Service plans</p>
<ul>
<li>Non isolated app service plan</li>
<li>Isolated app service plan</li>
</ul>
<h5>Non isolated app service plan</h5>
<ul>
<li>Free and shared (F1, D1)</li>
<li>Basic (B1, B2, B3) manual scale</li>
<li>
Standard (S1, S2, S3) can auto scale
<b>Recomended for production</b>
</li>
<li>Premium v2(P1v2, P2v2, P3v2)</li>
<li>Premium v3(P1v3, P2v3, P3v3)</li>
</ul>
<h5>Isolated app service plans (ASE)</h5>
<p>to consider when</p>
<ul>
<li>fully isolated environment for web app</li>
<li>
highly scalable & recomended for high memory utlization
apps
</li>
<li>isolated & secure nettwork access</li>
<li>fine control ofver network traffic</li>
<li>can connect using VPN</li>
</ul>
<p>plans available :</p>
<ul>
<li>I (I1,I2, I3)</li>
<li>Iv2 (I1v2, I2v2, I3v2)</li>
</ul>
<div id="html" class="section-block">
<div id="app-service-plan" class="code-block">
<h6>Create App Service Plan</h6>
<pre><code class="language-git">az appservice plan create --name "%lt;plan name>" \
--resource-group "<name of rg>" \
--sku s1 \
--is-linux</code></pre>
</div>
<!--//code-block-->
<div id="web-app" class="code-block">
<h6>Create Web App</h6>
<pre><code class="language-git">az webapp create -g "<name of rg>" \
-p "<name of app service plan>" \
-n "<name of webapp>" \
--runtime "node|10.14"</code></pre>
</div>
<!--//code-block-->
<p>
lastly you can deploy from various sources like
local-git, github, Azure DevOps, etc<br />
<a
href="https://docs.microsoft.com/en-us/azure/developer/javascript/tutorial/tutorial-vscode-azure-cli-node/tutorial-vscode-azure-cli-node-04"
target="_blank"
>Link to deploy from local git repo</a
>
</p>
</div>
<!--//section-block-->
</div>
<!--//section-block-->
</section>
<!--//doc-section-->
<section id="azure-functions" class="doc-section">
<h2 class="section-title">Azure Functions</h2>
<div class="section-block">
<p>
<a
href="https://docs.microsoft.com/en-us/azure/azure-functions/"
target="_blank"
>Link to official docs</a
><br />
It is a serverless platform to run small peices of code.
It can <b>auto scale</b> &you have to
<b
>pay only for the time yur code runs (consumption
plan)</b
>
<br />
one ting to note is that azure functions run on app
service plan and we have the following plans :
</p>
<ul>
<li>consumption plan (5 min limit timeout)</li>
<li>app service plan (Traditional pricing)</li>
<li>
premium plan (high speed, secuity, reserved instance)
</li>
</ul>
<h6>Important notes about Azure Functions</h6>
<ul>
<li>Azure Functions is a resource</li>
<li>run functions serverlessly</li>
<li>auto scales</li>
<li>cost depends on <b>App Service Plan</b></li>
<li>
steps: RG->app service plan->functions app(func
init)->func new
</li>
</ul>
<h3>Duable Functions</h3>
<p>
are azure one or mores fuctions chained together mostly
used for serverless workflows (orcastrations).
</p>
<h4>Orchestration patterns</h4>
<ul>
<li>function chaining</li>
<li>
fan out- fan in , exectes activityfunctions in parallel
and waits for them to end
</li>
<li>async http apis</li>
<li>monitor</li>
<li>human interaction</li>
</ul>
<h3>Azure functions App</h3>
<p>
is a resource used to group function in a single context
</p>
<h3>Development & workflow</h3>
<p>
you can write all the code manually but that is not a good
choice, so we have mainly 2 ways to develop locally and
then dpeoy.
</p>
<ul>
<li>Visual studio</li>
<li>Visual studio code with Azure core tools</li>
</ul>
<h4>Working with Azure Core Tools</h4>
<p>
Azure core tools is a cli application that helps to
develop Azure functions locally and deploy to cloud by
providing templates & easy commands for automation.
</p>
<h5>Create function project locally</h5>
<ul>
<li>
create functions project
<pre><code class="language-git">func init <projectName></code></pre>
</li>
<li>
create new function
<pre><code class="language-git">func new</code></pre>
</li>
<li>
start functions to test locally
<pre><code class="language-git">func start</code></pre>
</li>
<li>
deploy or publish to azure
<pre><code class="language-git">func azure functionapp publish <FunctionAppName></code></pre>
</li>
</ul>
</div>
</section>
<!--//doc-section-->
<section id="Service" class="doc-section">
<h2 class="section-title">Azure Cosmos DB</h2>
<div class="section-block">
<p>
<a
href="https://docs.microsoft.com/en-us/azure/cosmos-db/"
target="_blank"
>Link to official docs</a
><br />
It is a Fast <b>NoSQL</b> database with open APIs for any
scale.
</p>
<h6>Important notes about Azure Csmos DB</h6>
<ul>
<li>Azure Cosmos DB is a resource</li>
<li>provides low latency < 10ms</li>
<li>elastic scalabilty</li>
<li>pricing for throughput</li>
<li>builtin indexing</li>
<li>
steps: RG->cmos db account->database->container(Table,
Graph or collection)-> items
</li>
</ul>
<h3>APIs that Cosmos DB provides</h3>
<p>
Cosmos db provides with a wide rage of apis to intract
with the database.You can chose which API on the basics of
with which you are familier or some other tradeoffs.<br />
Here are the APIs
</p>
<ul>
<li>SQL <b>default</b></li>
<li>Cassandra</li>
<li>Mongo db</li>
<li>Gremlin</li>
<li>Azure Table</li>
</ul>
<p>
Lets have a look on each and see, Why you should you
<b>prefer a specific over other</b> APIs.
</p>
<h6>SQL</h6>
<ul>
<li>if you know SQL</li>
<li>you want to store data as json documents</li>
<li>if know other case fits choose SQL</li>
</ul>
<h6>Cassandra</h6>
<ul>
<li>if you know CQL</li>
<li>easy to migrate cassandra based dbs to cloud.</li>
<li>want to store data in wide coloumn format</li>
</ul>
<h6>Mongo db</h6>
<ul>
<li>if you know mongodb</li>
<li>easy to migrate mogodbs to cloud.</li>
<li>want to use json document store</li>
</ul>
<h6>Gremlin</h6>
<ul>
<li>need to store graph relations between data</li>
</ul>
<h6>Azure Table storage</h6>
<ul>
<li>if you know azure table storage</li>
<li>part of azure storage</li>
<li>easy to migrate azure table storage to Cosmos db.</li>
</ul>
<br />
<h5>Selecting SDK</h5>
<ul>
<li>
If using SQL API then use latest cosmosdb SDK for your
platform
</li>
<li>
If using cassandra, mongodb or gremin use current sdk
</li>
<li>If using Azure table api use current table sdks</li>
</ul>
<br />
<h5>Consistancy Levels</h5>
<ul>
<li>
<b>Strong :</b> gurantees that reads get the most recent
version of an item
</li>
<li>
<b>bounded staleness :</b> gurantees that reads has a
max lag of (either version or time)
</li>
<li>
<b>session consistency :</b> gurantees that clients
sessio will reads its own writes.
</li>
<li>
<b>consistent prefix consistancy :</b> gurantees that
updates are returned in order.
</li>
<li>
<b>Eventual Consistancy :</b> provides no gurantee for
order.
</li>
</ul>
</div>
<!--//section-block-->
<div id="Service-basic-template" class="section-block">
<div class="code-block">
<h6>Service basic template</h6>
<pre><code class="language-markup">
apiVersion: v1
kind: Service
metadata:
name: <service-name>
spec:
selector:
<label-key>: <label-value>
ports:
- port: <Pod-port>
targetPort: <container-exposed-port>
type: LoadBalancer</code></pre>
</div>
<!--//code-block-->
</div>
<!--//section-block-->
<div id="Service-using-cmd" class="section-block">
<div class="code-block">
<h6>Service using command line</h6>
<p>
For this you should have a <b>ReplicaSet</b> managing
one or more pods.
</p>
<pre><code class="language-git">kubectl expose rs <ReplicaSet-name> --name=<Service-name> --selector=<label-key>=<label-value> --port=<Pod-port> --target-port=<container-exposed-port> --type=LoadBalancer</code></pre>
</div>
<!--//code-block-->
</div>
<!--//section-block-->
</section>
<!--//doc-section-->
<section id="Probes" class="doc-section">
<h2 class="section-title">Azure Blob Storage</h2>
<div class="section-block">
<p>
<a
href="https://docs.microsoft.com/en-us/azure/storage/blobs/"
target="_blank"
>Link to official docs</a
><br />
Azure Blob Storage is Microsoft's object storage solution
for the cloud. Blob storage is optimized for storing
massive amounts of <b>unstructured data</b>.
</p>
<h6>Important notes about Azure Blob Storage</h6>
<ul>
<li>It is an object storage for the cloud</li>
<li>
You can store unstructured data like text files(html,
json, logs) binary files(images, videos, pdfs, virtial
disks of vm)
</li>
<li>accessabe via REST API over HTTP/HTTPS</li>
<li>
steps : RG->create storage account(globally unique
name)-> create Blob containers->blobs(files)
</li>
</ul>
<h5>Authorize access to blob storage</h5>
<p>
azure blob storage provides many ways to provide
authorized access to objects, along with the different
access levels <br />
</p>
<h6>Access levels</h6>
<ul>
<li>private (no read access without authorization)</li>
<li>Blob (can't list blobs in container)</li>
<li>Container (can list blobs in the container)</li>
</ul>
<h6>Authorization Types</h6>
<ul>
<li>shared key (storage account key)</li>
<li>shared access signature (SAS token)</li>
<li>Azure active directory</li>
<li>Anonymous (public read access)</li>
</ul>
<h5>Blob Types</h5>
<ul>
<li>block blob (images , videos)</li>
<li>append blob (log files)</li>
<li>page blobs (virtual disks)</li>
</ul>
<h5>Replication and Redundancy</h5>
<ul>
<li>
<b>LRS</b> : create 3 copies in the same zone (data
center).
</li>
<li>
<b>ZRS(not supported in all regions)</b> : creates 3
copies in 3 different zones(data centers) in the same
region.
</li>
<li>
<b>GRS</b> : creates 3 copies in the same zone (data
center) & 3 copies in a zone(data center) of secondary
region.
</li>
<li>
<b>GZRS</b> : creates 3 in 3 different zones(data
centers) in primaery region & 3 copies in a zone(data
center) of secondary region.
</li>
<li>
<b>RA-GRS (default for Storage v2)</b>: same as GRS but
you can read from secondary region.
</li>
<li>
<b>RA-GZRS</b> : same as GZRS but you can read from
secondary region.
</li>
</ul>
</div>
<!--//section-block-->
<ol>
<li>
<div id="Liveness-probe" class="section-block">
<div class="code-block">
<h4>Liveness probe</h4>
<p>
liveness probe checks our application again and
again after a spicific period of time to check if it
is working correctly
<br />If it fails it restarts the container.
<br />There are <b>3 types of liveness</b> probe
</p>
<ol>
<li>
http get => sends a http request and checks for
response
</li>
<li>
tcp socket => tries to make connection on
container port
</li>
<li>
exec => executes a command in the application
container to check if it is hanged
</li>
</ol>
<h6>HTTP GET basic template</h6>
<pre><code class="language-markup">
apiVersion: v1
kind: Pod
metadata:
labels:
<key>: <value>
name: <Pod-name>
spec:
containers:
- name: <container-name>
image: <container-image>
livenessProbe:
httpGet:
path: / #root
port: <Pod-port or container-port>
initialDelaySeconds: <delay before first check>
periodSeconds: <time to wait after each check>
</code></pre>
<h6>TCP socket basic template</h6>
<pre><code class="language-markup">
apiVersion: v1
kind: Pod
metadata:
name: <pod-name>
spec:
containers:
- name: <container-name>
image: <container-image>
ports:
- containerPort: 8080
livenessProbe:
tcpSocket:
port: <container-port>
initialDelaySeconds: <delay before first check>
periodSeconds: <time to wait after each check>
</code></pre>
<h6>EXEC basic template</h6>
<pre><code class="language-markup">
apiVersion: v1
kind: Pod
metadata:
name: <pod-name>
spec:
containers:
- name: <container-name>
image: <container-image>
livenessProbe:
exec:
command:
- <command eg: ls>
initialDelaySeconds: <delay before first check>
periodSeconds: <time to wait after each check>
</code></pre>
</div>
<!--//code-block-->
</div>
<!--//section-block-->
</li>
<li>
<div id="Readiness-probe" class="section-block">
<div class="code-block">
<h4>Readiness probe</h4>
<p>
Readiness checks our application again and again
after a spicific period of time to check if its is
working correctly
<br />If it fails it restricts access to container.
<br />There are <b>3 types of readiness</b> probe
</p>
<ol>
<li>