﻿
{"id":16829,"date":"2020-07-29T00:24:09","date_gmt":"2020-07-29T00:24:09","guid":{"rendered":"https:\/\/www.gencayyildiz.com\/blog\/?p=16829"},"modified":"2020-07-29T00:33:46","modified_gmt":"2020-07-29T00:33:46","slug":"azure-storage-serisi-6-azure-table-storage-ve-net-core","status":"publish","type":"post","link":"https:\/\/www.gencayyildiz.com\/blog\/azure-storage-serisi-6-azure-table-storage-ve-net-core\/","title":{"rendered":"Azure Storage Serisi #6 &#8211; Azure Table Storage ve Asp.NET Core \u0130le Kullan\u0131m\u0131"},"content":{"rendered":"<div id=\"fb-root\"><\/div>\n<p>Merhaba,<\/p>\n<p><a href=\"https:\/\/www.gencayyildiz.com\/blog\/azure-storage-yazi-dizisi\/\" rel=\"noopener noreferrer\" target=\"_blank\">Azure Storage Yaz\u0131 Dizisi<\/a>nin bu alt\u0131nc\u0131 makalesinde Azure Table Storage servisi \u00fczerine incelemede bulunuyor olaca\u011f\u0131z.<\/p>\n<h3 style=\"color:#e83e8c;\">Azure Table Storage Nedir?<\/h3>\n<p>Azure Table Storage, bir NoSQL veritaban\u0131 t\u00fcrevidir. Primary Key ve Foreign Key ihtiyac\u0131 olmaks\u0131z\u0131n veri tutmam\u0131z gerekti\u011finde bu veriyi ili\u015fkisel veritaban\u0131nda tutmaktansa NoSQL&#8217;de tutmay\u0131 tercih edebiliriz. NoSQL a\u00e7\u0131l\u0131msal olarak &#8216;Not Only SQL&#8217; yani &#8216;Sadece SQL De\u011fil&#8217; diyerek, bu ve bunun gibi ili\u015fkisel bir tasar\u0131m gerektirmeyen durumlarda standart SQL&#8217;in zaten var olan yo\u011funlu\u011fu i\u00e7erisinde ekstradan maliyeti artt\u0131rmaks\u0131z\u0131n NoSQL yakla\u015f\u0131m\u0131n\u0131 benimsemi\u015f bir veritaban\u0131 \u00fczerinden \u00e7\u00f6z\u00fcm getirilmesi ve b\u00f6ylece maliyetten d\u00fc\u015f\u00fclerek verisel i\u015flemlerde h\u0131z ve verimin artt\u0131r\u0131lmas\u0131 fikrini ortaya koymaktad\u0131r.<\/p>\n<p>NoSQL, yap\u0131sal olarak veriler \u00fczerinde statik alan tan\u0131mlamalar\u0131ndan ziyade daha esnek olan ve ihtiyaca binaen dinamik alan tan\u0131mlamas\u0131na imkan verdi\u011finden dolay\u0131 ili\u015fkisel veritabanlar\u0131nda olan sert kurallar\u0131 a\u015fabilmemizi sa\u011flamakta ve bu esnekli\u011fin getirisi olan verimlilikten dolay\u0131 tercih edilmektedir. NoSQL hakk\u0131nda daha detayl\u0131 ekstra bilgiler edinmek i\u00e7in <a href=\"https:\/\/www.gencayyildiz.com\/blog\/nosql-ve-mongodb-nedir\/\" rel=\"noopener noreferrer\" target=\"_blank\">buradaki<\/a> makaleyi okuman\u0131z\u0131 tavsiye ederim.<\/p>\n<blockquote style=\"color:red;\"><p><em>NoSQL ile Relational yakla\u015f\u0131mlar\u0131 birlikte kullan\u0131ld\u0131\u011f\u0131nda daha g\u00fc\u00e7l\u00fc, performansl\u0131 ve verimli olmaktad\u0131r.<\/em><\/p><\/blockquote>\n<h3 style=\"color:#e83e8c;\">Azure Table Storage&#8217;\u0131 Neden Kullanmal\u0131y\u0131z?<\/h3>\n<p>Azure Table Storage, NoSQL yakla\u015f\u0131m\u0131 benimsedi\u011finden dolay\u0131 uygulaman\u0131z\u0131n ihtiya\u00e7lar\u0131 geli\u015ftik\u00e7e verilerinizi uyarlamak daha kolay olacakt\u0131r. Benzer hacimlerdeki veriler i\u00e7in geleneksel SQL y\u00f6ntemlerine nazaran daha d\u00fc\u015f\u00fck maliyette sorgulamalar yapman\u0131z\u0131 sa\u011flayacakt\u0131r. Ayr\u0131ca <a href=\"https:\/\/www.gencayyildiz.com\/blog\/asp-net-core-web-api-odata-yazi-dizisi\/\" rel=\"noopener noreferrer\" target=\"_blank\">OData protokol\u00fc<\/a> ile yap\u0131lan sorgulamalarda NoSQL yakla\u015f\u0131mlar\u0131 olduk\u00e7a elveri\u015fli bir sonu\u00e7 do\u011furmaktad\u0131r.<\/p>\n<blockquote style=\"color:blue;\"><p><em>Azure Storage Table&#8217;\u0131n transaction deste\u011fi bulunmamaktad\u0131r. Bu durum kesinlikle NoSQL veritabanlar\u0131 i\u00e7in genellenmemelidir. \u00d6rne\u011fin; MongoDB NoSQL yakla\u015f\u0131m\u0131n\u0131 benimsemi\u015f bir veritaban\u0131d\u0131r ve transaction deste\u011fi bulunmaktad\u0131r.<\/em><\/p><\/blockquote>\n<h3 style=\"color:#e83e8c;\">Azure Table Storage Kavramlar\u0131 Nelerdir?<\/h3>\n<p><a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage.jpg\" alt=\"Azure Storage Serisi #6 - Azure Table Storage\" width=\"407\" height=\"245\" class=\"alignleft size-full wp-image-16841\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage.jpg 407w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-300x181.jpg 300w\" sizes=\"auto, (max-width: 407px) 100vw, 407px\" \/><\/a><\/p>\n<ul>\n<li><strong>URL Format<\/strong><br \/>\nAzure Storage Table account&#8217;u a\u015fa\u011f\u0131daki gibi bir url \u015fablonu kullan\u0131r.<br \/>\n<code style=\"color:red;\"><strong>https:\/\/&lt;storage account&gt; .table.core.windows.net\/<\/strong><\/code><\/p>\n<p>Bu adresi kullanarak direkt eri\u015fimde sa\u011flayabilir yahut OData protokol\u00fc ile url \u00fczerinden sorgulamada bulunabilirsiniz.\n<\/li>\n<li><strong>Entity<\/strong><br \/>\nBir olguya kar\u015f\u0131l\u0131k gelen ve sadece o olguyu modelleyen bir b\u00fct\u00fcnd\u00fcr. Azure storage&#8217;da bir entity&#8217;nin boyutu en fazla 1 MB olabilir ve en fazla 256 property bar\u0131nd\u0131rabilir. NoSQL&#8217;de ki(MongoDB) document&#8217;e kar\u015f\u0131l\u0131k gelir.\n<\/li>\n<li><strong>Table<\/strong><br \/>\nTable&#8217;lar entitylerin tutuldu\u011fu koleksiyonlard\u0131r. NoSQL yakla\u015f\u0131m\u0131n\u0131 benimsedikleri i\u00e7in i\u00e7erisinde tutulacak entityler tek tip olmak zorunda de\u011fildirler. NoSQL&#8217;de ki(MongoDB) collection&#8217;a kar\u015f\u0131l\u0131k gelir.\n<\/li>\n<li><strong>Properties<\/strong><br \/>\nEntity i\u00e7erisinde verileri key\/value format\u0131nda depolayabilmeye yarar. Yukar\u0131da bahsedildi\u011fi gibi bir entity i\u00e7erisinde en fazla 256 adet bulunabilir.\n<\/li>\n<\/ul>\n<p>Azure Table Storage&#8217;a bir veri eklendi\u011finde ilgili entity i\u00e7erisine default olarak &#8216;Row Key&#8217;, &#8216;Partition Key&#8217; ve &#8216;Timestamp&#8217; alanlar\u0131 eklenir.<\/p>\n<p><em style=\"color:red;\">Row Key<\/em>; Primary Key gibi d\u00fc\u015f\u00fcn\u00fclebilir. E\u015fsiz bir de\u011ferdir.<\/p>\n<p><em style=\"color:red;\">Partition Key<\/em>; entityleri gruplama ve h\u0131zl\u0131 arama i\u00e7in kullan\u0131l\u0131r. \u00d6rne\u011fin; User tablosunda t\u00fcm userlar\u0131n bulundu\u011fu \u015fehirleri partition key olarak i\u015faretlememiz \u015fehirleri gruplayacak ve arama esnas\u0131nda ilgili \u015fehir d\u0131\u015f\u0131nda olan userlar\u0131 aramaks\u0131z\u0131n s\u00fcrece b\u00fcy\u00fck avantaj sa\u011flayacakt\u0131r.<\/p>\n<p><em style=\"color:red;\">Timestamp<\/em>; Zaman damgas\u0131, verinin eklendi\u011fi tarihi tutacakt\u0131r.<\/p>\n<blockquote><p><em style=\"color:purple;\">Azure Table Storage, LINQ&#8217;i destekler&#8230;<\/em><\/p><\/blockquote>\n<h3 style=\"color:#e83e8c;\">Asp.NET Core \u0130le Azure Table Storage Kullan\u0131m\u0131<\/h3>\n<p>Azure Table Storage&#8217;\u0131 Asp.NET Core ile kullanabilmek i\u00e7in \u00f6ncelikle bir Class Library i\u00e7erisinde uygulamadan ba\u011f\u0131ms\u0131z Azure Storage ile ileti\u015fim kuran yap\u0131lanma olu\u015fturulmal\u0131d\u0131r. Ard\u0131ndan ilgili yap\u0131lanman\u0131n uygulama taraf\u0131ndan dependency edilerek kullan\u0131lmas\u0131 yaz\u0131l\u0131msal a\u00e7\u0131dan daha kullan\u0131\u015fl\u0131 ve efektif bir y\u00f6ntem olacakt\u0131r.<\/p>\n<p>Bunun i\u00e7in a\u015fa\u011f\u0131daki ad\u0131mlar\u0131 s\u0131ras\u0131yla uygulay\u0131n\u0131z;<\/p>\n<ul>\n<li><strong>Ad\u0131m 1<\/strong><br \/>\nHerhangi bir isimde bir class library olu\u015fturunuz. Ben &#8216;AzureStorage&#8217; ismini tercih edece\u011fim.\n<\/li>\n<li><strong>Ad\u0131m 2<\/strong><br \/>\n\u0130lgili class library&#8217;e &#8216;<a href=\"https:\/\/www.nuget.org\/packages\/Microsoft.Azure.Cosmos.Table\" rel=\"noopener noreferrer\" target=\"_blank\">Microsoft.Azure.Cosmos.Table<\/a>&#8216; paketini y\u00fckleyiniz.<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131.jpg\" alt=\"Azure Storage Serisi #6 - Azure Table Storage ve Asp.NET Core \u0130le Kullan\u0131m\u0131\" width=\"480\" height=\"143\" class=\"aligncenter size-full wp-image-16858\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131.jpg 480w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-300x89.jpg 300w\" sizes=\"auto, (max-width: 480px) 100vw, 480px\" \/><\/a>\n<\/li>\n<li><strong>Ad\u0131m 3<\/strong><br \/>\nAzure Table Storage&#8217;da tutulacak datan\u0131n entity&#8217;sini olu\u015fturunuz. Bizler burada &#8216;Product&#8217; isminde bir entity olu\u015fturarak \u00f6rneklendirmede bulunaca\u011f\u0131z.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n    public class Product : TableEntity\r\n    {\r\n        public string Name { get; set; }\r\n        public string No { get; set; }\r\n    }\r\n<\/pre>\n<p>Burada dikkat edilmesi gereken husus, olu\u015fturulan entitylerin &#8216;TableEntity&#8217; s\u0131n\u0131f\u0131ndan t\u00fcremesi gereklili\u011fidir.<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-1.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-1-300x111.jpg\" alt=\"\" width=\"300\" height=\"111\" class=\"alignleft size-medium wp-image-16861\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-1-300x111.jpg 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-1.jpg 564w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n&#8216;TableEntity&#8217; s\u0131n\u0131f\u0131n\u0131n detay\u0131na bakarsan\u0131z e\u011fer &#8216;PartitionKey&#8217;, &#8216;RowKey&#8217; ve &#8216;Timestamp&#8217; propertyleri i\u00e7erisinde haz\u0131r gelmekte ve b\u00f6ylece kendisinden t\u00fcreyen entity&#8217;e kal\u0131t\u0131msal olarak ilgili \u00f6zellikler kazand\u0131r\u0131lmaktad\u0131r.\n<\/li>\n<li><strong>Ad\u0131m 4<\/strong><br \/>\nArd\u0131ndan art\u0131k NoSQL sorgular\u0131n\u0131 ger\u00e7ekle\u015ftirebilmek ve storage ile ilgili i\u015flevleri yerine getirebilmek i\u00e7in &#8216;INoSQLStorage&#8217; isminde bir interface olu\u015fturunuz ve i\u00e7eri\u011fini a\u015fa\u011f\u0131daki gibi tasarlay\u0131n\u0131z.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n    public interface INoSQLStorage&lt;T&gt;\r\n    {\r\n        Task&lt;T&gt; Add(T entity);\r\n        Task&lt;T&gt; Get(string rowKey, string partitionKey);\r\n        Task&lt;T&gt; Delete(string rowKey, string partitionKey);\r\n        Task&lt;T&gt; Update(T entity);\r\n        IQueryable&lt;T&gt; All();\r\n        IQueryable&lt;T&gt; Query(Expression&lt;Func&lt;T, bool&gt;&gt; query);\r\n    }\r\n<\/pre>\n<\/li>\n<li><strong>Ad\u0131m 5<\/strong><br \/>\n&#8216;TableStorage&#8217; isminde bir class olu\u015fturunuz ve yukar\u0131da olu\u015fturulan &#8216;INoSQLStorage&#8217; interface&#8217;inden implemente ediniz ve i\u00e7eri\u011fini a\u015fa\u011f\u0131daki gibi geli\u015ftiriniz.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n    public class TableStorage&lt;T&gt; : INoSQLStorage&lt;T&gt; where T : TableEntity, new()\r\n    {\r\n        CloudTableClient _cloudTableClient;\r\n        CloudTable _cloudTable;\r\n        public TableStorage()\r\n        {\r\n            CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(&quot;DefaultEndpointsProtocol=https;Acco******s1BxP4MT7tTeHbNe\/WljTCZQt7RfMr5UqVbKnuGTrtA=*********re.windows.net&quot;);\r\n            _cloudTableClient = cloudStorageAccount.CreateCloudTableClient();\r\n            _cloudTable = _cloudTableClient.GetTableReference(typeof(T).Name);\r\n            _cloudTable.CreateIfNotExists();\r\n        }\r\n        public async Task&lt;T&gt; Add(T entity)\r\n        {\r\n            TableOperation operation = TableOperation.InsertOrMerge(entity);\r\n            return (await _cloudTable.ExecuteAsync(operation)).Result as T;\r\n        }\r\n        public IQueryable&lt;T&gt; All() =&gt; _cloudTable.CreateQuery&lt;T&gt;().AsQueryable();\r\n        public async Task&lt;T&gt; Delete(string rowKey, string partitionKey)\r\n        {\r\n            TableOperation operation = TableOperation.Delete(await Get(rowKey, partitionKey));\r\n            return (await _cloudTable.ExecuteAsync(operation)).Result as T;\r\n        }\r\n        public async Task&lt;T&gt; Get(string rowKey, string partitionKey)\r\n        {\r\n            TableOperation operation = TableOperation.Retrieve&lt;T&gt;(partitionKey, rowKey);\r\n            return (await _cloudTable.ExecuteAsync(operation)).Result as T;\r\n        }\r\n        public IQueryable&lt;T&gt; Query(Expression&lt;Func&lt;T, bool&gt;&gt; query) =&gt; _cloudTable.CreateQuery&lt;T&gt;().Where(query);\r\n        public async Task&lt;T&gt; Update(T entity)\r\n        {\r\n            TableOperation operation = TableOperation.Replace(entity);\r\n            return (await _cloudTable.ExecuteAsync(operation)).Result as T;\r\n        }\r\n    }\r\n<\/pre>\n<p>Yukar\u0131daki kod blo\u011funu incelerseniz e\u011fer; <strong>3.<\/strong> sat\u0131rdaki &#8216;CloudTableClient&#8217; s\u0131n\u0131f\u0131 t\u00fcm tablolara, <strong>4.<\/strong> sat\u0131rdaki &#8216;CloudTable&#8217; s\u0131n\u0131f\u0131 ise sadece tek bir tabloya kar\u015f\u0131l\u0131k gelmektedir. <strong>7.<\/strong> sat\u0131rdaki &#8216;CloudStorageAccount&#8217; s\u0131n\u0131f\u0131 ise Azure Storage account&#8217;una kar\u015f\u0131l\u0131k gelmektedir. Burada ilgili account ile ba\u011flant\u0131 sa\u011flayabilmek i\u00e7in connection string de\u011feri kullan\u0131lmaktad\u0131r. Bu de\u011feri bulabilmek i\u00e7in <a href=\"https:\/\/portal.azure.com\/\" rel=\"noopener noreferrer\" target=\"_blank\">portal<\/a> \u00fczerinden &#8216;Storage accounts&#8217;a gelerek ilgili account&#8217;a girdikten sonra &#8216;Access keys&#8217; sekmesine t\u0131klay\u0131n\u0131z ve kar\u015f\u0131n\u0131za gelen ekrandan &#8216;Connection string&#8217; de\u011ferini kopyalay\u0131n\u0131z.<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-2.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-2.jpg\" alt=\"Azure Storage Serisi #6 - Azure Table Storage ve Asp.NET Core \u0130le Kullan\u0131m\u0131\" width=\"1831\" height=\"537\" class=\"aligncenter size-full wp-image-16867\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-2.jpg 1831w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-2-300x88.jpg 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-2-1024x300.jpg 1024w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-2-768x225.jpg 768w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-2-1536x450.jpg 1536w\" sizes=\"auto, (max-width: 1831px) 100vw, 1831px\" \/><\/a><\/p>\n<p>Ayr\u0131ca <strong>10.<\/strong> sat\u0131rdaki &#8216;CreateIfNotExists&#8217; metodu ile ilgili tablo yoksa cloud&#8217;da olu\u015fturulmaktad\u0131r.<\/p>\n<p>Bu a\u015famadan sonra class library in\u015fas\u0131 tamamlanm\u0131\u015ft\u0131r. Art\u0131k Asp.NET Core uygulamas\u0131n\u0131 geli\u015ftirmeye ba\u015flayabilirsiniz.\n<\/li>\n<li><strong>Ad\u0131m 6<\/strong><br \/>\nHerhangi bir isimde Asp.NET Core uygulamas\u0131 olu\u015fturunuz ve ilk olarak yukar\u0131da olu\u015fturulan class library&#8217;i ilgili projeye dependency ediniz.\n<\/li>\n<li><strong>Ad\u0131m 7<\/strong><br \/>\nArd\u0131ndan ilgili class library&#8217;de in\u015fa edilen &#8216;TableStorage&#8217; s\u0131n\u0131f\u0131n\u0131 uygulamaya servis olarak ekleyiniz.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n    public class Startup\r\n    {\r\n        .\r\n        .\r\n        .\r\n        public void ConfigureServices(IServiceCollection services)\r\n        {\r\n            .\r\n            .\r\n            .\r\n            services.AddSingleton(typeof(INoSQLStorage&lt;&gt;), typeof(TableStorage&lt;&gt;));\r\n            .\r\n            .\r\n            .\r\n        }\r\n\r\n        .\r\n        .\r\n        .\r\n    }\r\n<\/pre>\n<\/li>\n<li><strong>Ad\u0131m 8<\/strong><br \/>\nVe son olarak &#8216;ProductsController&#8217; isminde bir controller s\u0131n\u0131f\u0131 olu\u015fturunuz ve i\u00e7erisini a\u015fa\u011f\u0131daki gibi geli\u015ftiriniz.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n    &#x5B;Route(&quot;api\/&#x5B;controller]&quot;)]\r\n    &#x5B;ApiController]\r\n    public class ProductsController : ControllerBase\r\n    {\r\n        INoSQLStorage&lt;Product&gt; _noSQLStorage;\r\n        public ProductsController(INoSQLStorage&lt;Product&gt; noSQLStorage)\r\n        {\r\n            _noSQLStorage = noSQLStorage;\r\n        }\r\n        &#x5B;HttpGet()]\r\n        public IActionResult GetProducts()\r\n        {\r\n            return Ok(_noSQLStorage.All());\r\n        }\r\n        &#x5B;HttpGet(&quot;{rowKey}&quot;)]\r\n        public IActionResult GetProduct(string rowKey)\r\n        {\r\n            return Ok(_noSQLStorage.Query(p =&gt; p.RowKey == rowKey));\r\n        }\r\n        &#x5B;HttpPost()]\r\n        public async Task&lt;IActionResult&gt; Create(Product product)\r\n        {\r\n            Product created = await _noSQLStorage.Add(product);\r\n            return Ok(created);\r\n        }\r\n        &#x5B;HttpDelete()]\r\n        public async Task&lt;IActionResult&gt; Delete(string rowKey, string partitionKey)\r\n        {\r\n            Product deleted = await _noSQLStorage.Delete(rowKey, partitionKey);\r\n            return Ok(deleted);\r\n        }\r\n        &#x5B;HttpPut]\r\n        public async Task&lt;IActionResult&gt; Update(Product product)\r\n        {\r\n            Product updated = await _noSQLStorage.Update(product);\r\n            return Ok(updated);\r\n        }\r\n    }\r\n<\/pre>\n<\/li>\n<\/ul>\n<p>T\u00fcm bu ad\u0131mlar\u0131n ba\u015ftan sona ger\u00e7ekle\u015ftirilmesi neticesinde \u00f6rnek Azure Table Storage uygulamas\u0131 geli\u015ftirilmi\u015f olacakt\u0131r.<\/p>\n<p><strong>Test Edelim<\/strong><br \/>\nTestimizi Postman arac\u0131l\u0131\u011f\u0131yla ger\u00e7ekle\u015ftirelim.<\/p>\n<table>\n<thead>\n<tr>\n<th width=\"50%\">POST<\/th>\n<th>GET<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-3.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-3.jpg\" alt=\"Azure Storage Serisi #6 - Azure Table Storage ve Asp.NET Core \u0130le Kullan\u0131m\u0131\" width=\"473\" height=\"483\" class=\"aligncenter size-full wp-image-16878\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-3.jpg 473w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-3-294x300.jpg 294w\" sizes=\"auto, (max-width: 473px) 100vw, 473px\" \/><\/a>\n<\/td>\n<td>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-4.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-4.jpg\" alt=\"Azure Storage Serisi #6 - Azure Table Storage ve Asp.NET Core \u0130le Kullan\u0131m\u0131\" width=\"487\" height=\"550\" class=\"aligncenter size-full wp-image-16879\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-4.jpg 487w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-4-266x300.jpg 266w\" sizes=\"auto, (max-width: 487px) 100vw, 487px\" \/><\/a>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<table>\n<thead>\n<tr>\n<th width=\"50%\">PUT<\/th>\n<th>DELETE<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-6.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-6.jpg\" alt=\"Azure Storage Serisi #6 - Azure Table Storage ve Asp.NET Core \u0130le Kullan\u0131m\u0131\" width=\"580\" height=\"524\" class=\"aligncenter size-full wp-image-16881\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-6.jpg 580w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-6-300x271.jpg 300w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/a><\/td>\n<td><a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-5.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-5.jpg\" alt=\"Azure Storage Serisi #6 - Azure Table Storage ve Asp.NET Core \u0130le Kullan\u0131m\u0131\" width=\"437\" height=\"345\" class=\"aligncenter size-full wp-image-16880\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-5.jpg 437w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-5-300x237.jpg 300w\" sizes=\"auto, (max-width: 437px) 100vw, 437px\" \/><\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Put operasyonu Timestamp \u00f6zelli\u011fi \u00fczerinden otomatik olarak olas\u0131 veri tutars\u0131zl\u0131\u011f\u0131n\u0131n \u00f6nlemini almaktad\u0131r. <span style=\"font-size:11px;\">Bknz : <a href=\"https:\/\/www.gencayyildiz.com\/blog\/entity-framework-core-data-concurrency\/\" rel=\"noopener noreferrer\" target=\"_blank\">Entity Framework Core \u2013 Data Concurrency<\/a><\/span> E\u011fer ki, bir tutars\u0131zl\u0131k s\u00f6z konusu olursa a\u015fa\u011f\u0131daki gibi try &#8211; catch bloklar\u0131 arac\u0131l\u0131\u011f\u0131yla &#8216;StorageException&#8217; t\u00fcr\u00fc ile hatay\u0131 yakalay\u0131p manip\u00fcle edebilirsiniz.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n        &#x5B;HttpPut]\r\n        public async Task&lt;IActionResult&gt; Update(Product product)\r\n        {\r\n            try\r\n            {\r\n                Product updated = await _noSQLStorage.Update(product);\r\n                return Ok(updated);\r\n            }\r\n            catch (StorageException ex)\r\n            {\r\n                if (ex.RequestInformation.HttpStatusCode == (int)HttpStatusCode.PreconditionFailed)\r\n                    return Ok(&quot;PreconditionFailed Exception&quot;);\r\n                return Ok(ex.Message);\r\n            }\r\n        }\r\n<\/pre>\n<p>Ya da veri tutars\u0131zl\u0131\u011f\u0131n\u0131n g\u00f6z ard\u0131 edilmesini istiyorsan\u0131z &#8216;ETag&#8217; property&#8217;sine * de\u011ferini verebilirsiniz.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n        &#x5B;HttpPut]\r\n        public async Task&lt;IActionResult&gt; Update(Product product)\r\n        {\r\n            try\r\n            {\r\n                product.ETag = &quot;*&quot;;\r\n                Product updated = await _noSQLStorage.Update(product);\r\n                return Ok(updated);\r\n            }\r\n            catch (StorageException ex)\r\n            {\r\n                if (ex.RequestInformation.HttpStatusCode == (int)HttpStatusCode.PreconditionFailed)\r\n                    return Ok(&quot;PreconditionFailed Exception&quot;);\r\n                return Ok(ex.Message);\r\n            }\r\n        }\r\n<\/pre>\n<p>Not: Yap\u0131lan \u00e7al\u0131\u015fmalar\u0131 localde <a href=\"https:\/\/www.gencayyildiz.com\/blog\/azure-storage-serisi-4-azure-storage-explorer\/\" rel=\"noopener noreferrer\" target=\"_blank\">Azure Storage Explorer<\/a> uygulamas\u0131ndan takip etmek istiyorsan\u0131z e\u011fer &#8216;Microsoft Azure Storage Emulator&#8217; uygulamas\u0131n\u0131n ba\u015flat men\u00fcs\u00fcnden \u00e7al\u0131\u015ft\u0131r\u0131lm\u0131\u015f olmas\u0131 gerekmektedir.<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-7.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-7.jpg\" alt=\"Azure Storage Serisi #6 - Azure Table Storage ve Asp.NET Core \u0130le Kullan\u0131m\u0131\" width=\"836\" height=\"466\" class=\"aligncenter size-full wp-image-16892\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-7.jpg 836w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-7-300x167.jpg 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-7-768x428.jpg 768w\" sizes=\"auto, (max-width: 836px) 100vw, 836px\" \/><\/a><br \/>\n<div id=\"attachment_16894\" style=\"width: 795px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-8.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-16894\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-8.jpg\" alt=\"Azure Storage Serisi #6 - Azure Table Storage ve Asp.NET Core \u0130le Kullan\u0131m\u0131\" width=\"785\" height=\"485\" class=\"size-full wp-image-16894\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-8.jpg 785w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-8-300x185.jpg 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-8-768x474.jpg 768w\" sizes=\"auto, (max-width: 785px) 100vw, 785px\" \/><\/a><p id=\"caption-attachment-16894\" class=\"wp-caption-text\">Microsoft Azure Storage Emulator \u00e7al\u0131\u015ft\u0131rd\u0131ktan sonra Console \u00e7\u0131kt\u0131s\u0131&#8230;<\/p><\/div><\/p>\n<p>Tabi Azure Storage Explorer ile localde \u00e7al\u0131\u015facaksan\u0131z e\u011fer &#8216;TableStorage&#8217; s\u0131n\u0131f\u0131nda localin connection string de\u011feri tan\u0131mlanm\u0131\u015f olmas\u0131 gerekiyor. Bunun i\u00e7in, Azure Storage Explorer uygulamas\u0131n\u0131n &#8216;Explorer&#8217; penceresinde &#8216;Local&#038;Attached&#8217; -> &#8216;Storage Accounts&#8217; -> &#8216;(Emulator &#8211; Default Ports) (Key)&#8217; kombinasyonuna t\u0131klad\u0131\u011f\u0131n\u0131zda a\u015fa\u011f\u0131daki &#8216;Properties&#8217; sekmesine gelen &#8216;Primary Connection String&#8217; de\u011ferini kopyalaman\u0131z yeterli olacakt\u0131r.<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-9.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-9.jpg\" alt=\"Azure Storage Serisi #6 - Azure Table Storage ve Asp.NET Core \u0130le Kullan\u0131m\u0131\" width=\"635\" height=\"505\" class=\"aligncenter size-full wp-image-16896\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-9.jpg 635w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-9-300x239.jpg 300w\" sizes=\"auto, (max-width: 635px) 100vw, 635px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-10.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-10.jpg\" alt=\"Azure Storage Serisi #6 - Azure Table Storage ve Asp.NET Core \u0130le Kullan\u0131m\u0131\" width=\"920\" height=\"299\" class=\"aligncenter size-full wp-image-16898\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-10.jpg 920w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-10-300x98.jpg 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/Azure-Storage-Serisi-6-Azure-Table-Storage-ve-Asp.NET-Core-\u0130le-Kullan\u0131m\u0131-10-768x250.jpg 768w\" sizes=\"auto, (max-width: 920px) 100vw, 920px\" \/><\/a><\/p>\n<p>\u0130lgilenenlerin faydalanmas\u0131 dile\u011fiyle&#8230;<br \/>\nSonraki yaz\u0131lar\u0131mda g\u00f6r\u00fc\u015fmek \u00fczere&#8230;<br \/>\n\u0130yi \u00e7al\u0131\u015fmalar&#8230;<\/p>\n<p>Not : \u00d6rnek projeyi indirmek i\u00e7in <a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/07\/AzureTableStorageExample.zip\">buraya<\/a> t\u0131klay\u0131n\u0131z.<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Merhaba, Azure Storage Yaz\u0131 Dizisinin bu alt\u0131nc\u0131 makalesinde Azure Table Storage servisi \u00fczerine incelemede bulunuyor olaca\u011f\u0131z. Azure Table Storage Nedir? Azure Table Storage, bir NoSQL veritaban\u0131 t\u00fcrevidir. Primary Key ve Foreign Key ihtiyac\u0131 olmaks\u0131z\u0131n&#46;&#46;&#46;<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":16718,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3121],"tags":[3644,3642,3604,3641,3645,3648,3647,3646,3650,3649,3643,2935],"class_list":["post-16829","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure","tag-azure-partition-key","tag-azure-row-key","tag-azure-storage","tag-azure-table-storage","tag-azure-timestamp","tag-cloudstorageaccount","tag-cloudtable","tag-cloudtableclient","tag-microsoft-azure-storage-emulator","tag-microsoft-azure-storage-explorer","tag-partition-key","tag-timestamp"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/16829","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/comments?post=16829"}],"version-history":[{"count":59,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/16829\/revisions"}],"predecessor-version":[{"id":16905,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/16829\/revisions\/16905"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media\/16718"}],"wp:attachment":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media?parent=16829"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/categories?post=16829"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/tags?post=16829"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}