Azure function basic code

#r “Newtonsoft.Json” using System.Net; using Newtonsoft.Json; using System.Text; public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log) { try { log.Info(“C# HTTP trigger function processed a request.”); var data = await req.Content.ReadAsStringAsync(); var json = (Newtonsoft.Json.Linq.JObject)JsonConvert.DeserializeObject(data); json.Remove(“etag”); return new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(json.ToString(), Encoding.UTF8, “application/json”) }; } catch (Exception ex) { HttpResponseMessage res =… Read More Azure function basic code

Get insert Id from stored proc sql using OUTPUT

ALTER PROCEDURE sp_Mydemo — Add the parameters for the stored procedure here @Name nvarchar (520), @Date nvarchar (520), AS BEGIN insert into data.MyTable (Name,Date) OUTPUT INSERTED.Id values (@Name,@Date) END GO call sp – DECLARE @Name nvarchar (520) = ‘test’; DECLARE @Date nvarchar (520)= ‘2018-03-22 14:57:41.687’; exec sp_Mydemo @Name , @Date it will return new GUID… Read More Get insert Id from stored proc sql using OUTPUT

upload files from sharepoint document to azure blob storage using c#

public static void GetFiles() { // Azure Blob Storage Code CloudStorageAccount storageAccount = CloudStorageAccount.Parse( CloudConfigurationManager.GetSetting(“StorageConnectionString”)); CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); CloudBlobContainer container = blobClient.GetContainerReference(“mycontainer”); container.CreateIfNotExists(); // Sharepoint Object Model Code ClientContext clientContext = new ClientContext(“http://ipaddess:8080/&#8221;); clientContext.Credentials = new NetworkCredential(“username”, “password”); Web web = clientContext.Web; clientContext.Load(web); clientContext.Load(web.Lists); clientContext.Load(web, wb => wb.ServerRelativeUrl); clientContext.ExecuteQuery(); List list = web.Lists.GetByTitle(“Shared Documents”);… Read More upload files from sharepoint document to azure blob storage using c#

HttpClient POST call with header value

string ff = “{\”destination\”: \”http://localhost:58125/default.aspx\”,\”domain\”: { \”fullName\”: \”name\” }}”;             var client = new HttpClient();             var httpContent = new StringContent(ff, Encoding.UTF8, “application/json”);             var request = new HttpRequestMessage();             //request.Headers.Add(“Content-Type”, “application/json”);             request.Headers.Add(“apikey”, “test”);             request.RequestUri = new Uri(“https://url&#8221;);             request.Content = httpContent;             request.Method = HttpMethod.Post;             var response = client.SendAsync(request).Result;             var ss = response.Content.ReadAsStringAsync(); ;             var json = ss.Result;             JObject obj =… Read More HttpClient POST call with header value

Read Sharepoint Documents using c# code

class Program { static void Main(string[] args) { GetFiles(); } public static void GetFiles() { ClientContext clientContext = new ClientContext(“http://ipaddress:8080/&#8221;); clientContext.Credentials = new NetworkCredential(“username”, “pass”); Web web = clientContext.Web; clientContext.Load(web); clientContext.Load(web.Lists); clientContext.Load(web, wb => wb.ServerRelativeUrl); clientContext.ExecuteQuery(); List list = web.Lists.GetByTitle(“Shared Documents”); clientContext.Load(list); clientContext.ExecuteQuery(); Folder folder = web.GetFolderByServerRelativeUrl(web.ServerRelativeUrl + @”Shared Documents\1″); clientContext.Load(folder); clientContext.ExecuteQuery(); CamlQuery camlQuery =… Read More Read Sharepoint Documents using c# code