Posts

Azure Search #2–Creating Search Service

Image
  Let’s see how we can create a azure search service and how we can manage and scale it. Step 1: Select Search service from add new Log in to Azure portal Click New –> Web & Mobile Under that select Azure Search . Step 2: Give a name & select pricing tier after selecting the Azure Search you will get the following blade. enter the name you need to use for the search service. then you have to select the pricing tier, by clicking on Pricing tier option in the blade. when selecting pricing tier you need to identify your application requirements and select it. Anyway it is always better you start with a lower tier and scale it up when the application need varies. Azure provides you the facility of scaling up or down the tier based on you need. Then click create search service will be created for you. Pricing Tiers mainly contains 3 categories. 1.Free multi-tenant shared service 2.Basic provides dedicated computing resources for production workloads at ...

Azure Search #3 - Azure Search Index

  When you want to have Azure Search integrated with your application data first thing you have to do is creating a Azure Search index under your search service. One Search service can contain multiple indexes. An index is a persistent store of documents and other constructs used by an Azure Search service. A document is a single unit searchable data in your index. Index is like a table in SQL database. But there are some differences. When creating a index a given data field has set of attributes and a field type. Lets first look at what are the possible data types we can store in Azure search index.   Type Description Edm.String Text that can optionally be tokenized for full-text search Collection(Edm.String) A list of strings that can optionally be tokenized for full-text search Edm.Boolean Contains true/false values Edm.Int32 32-bit integer values Edm.Int64 64-bit integer values Edm.Double Double-precision numeric data Edm.DateTimeOff...

Covert Image URL in to base64 string

Suppose you have your images hosted in azure blob storage. And you access the images using the URL. Else you have some images from another online location where you have only the URL. I got a requirement recently on a project to generate a Vcard. For that I need the base64 string of the image, as all the data will be saved in to a text file. So I used the following code to first download the image them convert it to base64 string. public String GetImageData(String url) { StringBuilder _sb = new StringBuilder(); Byte[] _byte = GetImage(url); //convert byte array in to base 64 string _sb.Append(Convert.ToBase64String(_byte, 0, _byte.Length)); return _sb.ToString(); } // Download image in to byte array private byte[] GetImage(string url) { Stream stream = null; byte[] buf; try { WebProxy myProxy = new WebProxy(); HttpWebRequest req = (HttpWebRe...

Azure Push Notification with Web API

Image
Before explaining how to to push notification to hub using Web API, let us see what is azure push notifications hub provides. Azure Notification Hubs provide an easy-to-use, multiplatform, scaled-out push infrastructure that enables you to send mobile push notifications from any backend (in the cloud or on-premises) to any mobile platform. With Notification Hubs you can easily send cross-platform, personalized push notifications, abstracting the details of the different platform notification systems (PNS). With a single API call, you can target individual users or entire audience segments containing millions of users, across all their devices. Step 1 : Create Push Notification Hub Log on to the Azure Portal , and then click +NEW at the top left of the screen. Click on New , then Web + Mobile . Scroll down if necessary and click Notification Hub . Add All the details and create the hub Step 2 : Add Keys After creating the hub next you need to add keys...

Azure Search #1

Image
  I will be writing a series of post on azure search step by step. Each post I will be explaining different areas in azure search. As this is the first post I will be explaining what azure search is and what are the applications of azure search. What is Azure Search ? A search-as-a-service solution allowing developers to incorporate great search experiences into applications without managing infrastructure or needing to become search experts. If I elaborate the definition bit more,Azure search provides lot of services, which allows developer to add high search experience to their end users, without been a search expert. In other words developer has to call some API calls to azure search all the search algorithms will be executed by azure search service and result will be returned. this makes developer life easier and giving end user a high search experience. Why we need search? Search box in an application has been the main entry point of most of the applications. If we una...

Saving Base64 String as image to Azure Blob Storage

  Recently I started working on a API which supports mobile backend. I got the following requirement 1. When user uploads a image to their profile API will get the base64 string of the image 2. When viewing the User profile to increase the performance of service calls have to send an image URL rather base64 string   Solution : Save the base 64 string in the azure storage & save it in DB public class AzureBlogService { private static string _connectionString = "DefaultEndpointsProtocol=https;AccountName=****;AccountKey=****"; public static string UploadImage(string imageData, ImageType imageType, int cardId) { string filename = GetFileName(imageType, cardId); CloudBlobContainer container = GetContainer("userimages"); byte[] imageBytes = Convert.FromBase64String(imageData); CloudBlockBlob blob = container.GetBlockBlobReference(filename); blob.Properties.Cont...

Group By First Letter of word with Linq

  This is sample code which you can used to group some list of objects based on first letter of the object name or any string property. In the following example I get list of contacts in an application and after getting those from DB , I group them with the First letter of the Contact name and order them in alphabetical order. Following is my Contact Class. public class CardContactModel { public int CardId { get; set; } public string CardName { get; set; } public int? ContactId { get; set; } public JObject Information { get; set; } public string ProfileImage { get; set; } public string SharedTo { get; set; } public string RecievedFrom { get; set; } } Then I group it and add it to a dictionary with the following line of code. Dictionary > Contacts = contacts.GroupBy(x => x.CardName.Substring(0, 1).ToUpper(), (Letter, Contacts) => new { Alphabet = Letter, SubList = Contacts.OrderBy(...