Getting Started with Azure Blob and other Storage Service

Azure Blob is a cloud storage service from Azure, and great to master if your web service needs to store binary data and text.

  • Index
    • Understanding Structure of Blob Service
    • CRUD of Container
    • CRUD of Blob

The master document of how to is here; https://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-blobs/

What is Azure Blob storage?

Azure Blob storage is a service that stores file data in the cloud. Blob storage can store any type of text or binary data, such as a document, media file, or application installer. Blob storage is sometimes referred to as object storage.

OK. Azure Blob sounds like service for almost all web services.

What is Blob Storage

It is a service for storing large amounts of unstructured data, such as text or binary data, that can be accessed from anywhere in the world via HTTP or HTTPS. You can use Blob storage to expose data publicly to the world, or to store application data privately.

Common uses of Blob storage include:Serving images or documents directly to a browser.  Storing files for distributed access.  Streaming video and audio.  Performing secure backup and disaster recovery.  Storing data for analysis by an on-premises or Azure-hosted service

Great these are all thing I want to do.  Let’s see how we can use this service. Continue reading “Getting Started with Azure Blob and other Storage Service”

Note on HTTP/2

This is me taking note on HTTP/2.

What is the problem with HTTP/1.1 ?

Modern websites requires lots of resources.  And resources are communicated through TCP, and TCP is slow in starting, because it required key value exchanges, three way hands shaking etc.  And we call that RTT (Round Trip Time).

Some uses KeepAlive flag to keep single connection and use this single connection with multiple resources.  But this also have problem, because when one resource takes up time, all resources behind the line gets stuck.

With TCP/1.1, it made it possible to have 6 instances of resources to be handled at same time.

What people try to do within limitation of HTTP/1.1.

6 is better than 1 but demand for resources to travel over http exceed 6 times more, so people had to come up with ways to reduce request over http.

Continue reading “Note on HTTP/2”

Setting DisplayFormat at Model

You can set how you want to format your data at Model level by using DisplayFormat. It is simple yet deep and worthy to master.

Microsoft put documents here:

Typically when you have numerical value in your database, it is stored like “123123121”.  But I want to show it like “123,123,121” for better readability, then simply make your model like below;

You can format at view level too, but if you are using one model at multiple views and you want all views to have them in same format, this is better.

DisplayFormat for date and time

If you need to know more about date time format please read: https://msdn.microsoft.com/en-us/library/system.datetime(v=vs.110).aspx

When you get validation error on DB, but.. don’t know what.

One day soon, my blog is going to be filled with lists of errors and what to do about them.

When you are working with data, (and who doesn’t work with data today..)  you may encounter validation error.  The error is straight forward, you are trying to insert invalid data.

The problem is that invalid error is not easy to see, specially when you have multiple fields.

You can write catch code like below and find some more insights.

 

Mastering Azure Search

Azure Search is a great Search-as-a-service from Azure.  It is powerful yet easy to implement from not just ASP.Net C# but from other platforms too.

The service let you index data and let you do full text search or facet, with features like search scores and suggestions.

Refer to: https://azure.microsoft.com/en-us/services/search/

The service is fully available through REST API, or by using .NET SDK.  The full control over API is great, but me – lazy guy – will go with .NET SDK to implement first.

Continue reading “Mastering Azure Search”

Domain Authority

Domain Authority is said created by Moz, great SEO tools (that I use too). Domain Authority is a score to the domain name.  It is basically the answer to “how trust worthy is this domain?”.

Refer to: https://moz.com/learn/seo/domain-authority

We score Domain Authority on a 100-point, logarithmic scale. Thus, it’s easier to grow your score from 20 to 30 than it would be to grow from 70 to 80.

Of course the higher is better.  So, how can you get higher domain authority? No one knows all things nor need to know all things, but I ll write what I know.

In the world of web pages, your web page is linked to other web pages, and that’s how Google and other real humans find you.  Google crawlers, wonder around in the world of web pages and see who and how you are connected to.  That’s Domain Authority.

And same goes for IP addresses.  You may have 100 references from 100 different domains, but one IP (server) address.  Then, you aren’t trust worthy as one with 100 unique IP addresses, in general.

And these links are not just one to one, you have to consider multi depth path to your site from the link.

So.. go get good links.  Yes, I know, You know, Everyone knows.  But, how to build and get good links? or should you even care about this..  I ll cover this more.

Conflicts between different versions of the same dependent assembly

Warning Found conflicts between different versions of the same dependent assembly that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed.

Everyday I still (and ever will) encounter new error that I have never seen before.  And this is it today.

OK.. picking up keywords from the warning message, Assembly, different versions, conflict problems.  I wonder which which assemblies.

oh well let’s go to NuGet and make sure all things are updated.   I see Jquery and Newtonsoft.Json needing to be updated, and I did.

And fixed.

Input Validation from Model

If you want to improve user experience of your web services, you need to work on easy and friendly input interfaces for users through out.  Input validation being one of them, and validating user input for ASP.Net MVC is simple and intuitive.  You can use below at Model.

  • Required()
    • This makes specific field a required field.
  • MaxLength(max)
    • This specifies max length users can input for the field.
  • MinLength(min)
    • This specifies min length users can input for the field.
  • Range(min, max)
    • This specifies range of length (from min to max) users can input for the field.
  • RegularExpression(pattern)
    • This specified regular expression that users must match for the field.
  • EmailAddress()
    • The field must be email address. you can do same with RegulareExpression(pattern)
  • Url()
    • The field must be url.
  • Compare(other)
    • The field must match other.
  • CustomValidation(type,method)
    • This calls custom validation.

*The Model must make reference to System.ComponentModel and System.ComponentModel.DataAnnotations.

You can refer to http://www.asp.net/mvc/overview/getting-started/introduction/adding-validation too.

 

Global.asax

Global.asax is a global event handling file in App_Start folder.  This file is read first, and you can specify events and actions at app level.

When you save changes to an active Global.asax file, the ASP.NET page framework detects that the file has been changed. It completes all current requests for the application, sends the Application_OnEnd event to any listeners, and restarts the application domain. In effect, this reboots the application, closing all browser sessions and flushing all state information. When the next incoming request from a browser arrives, the ASP.NET page framework reparses and recompiles the Global.asax file and raises the Application_OnStart event.

https://msdn.microsoft.com/en-us/library/1xaas8a2(v=vs.71).aspx