Explore Public Snippets
Found 1,894 snippets matching: azure
RoleEnvironment.TraceSource.Switch.Level = SourceLevels.Information;
using System; using System.Linq; using System.Net; using System.Collections.Generic; public static IPEndPoint ResolveToEndPoint(string value) { if (String.IsNullOrEmpty(value)) throw new ArgumentNullException("value"); var parts = value.Split(':'); if (parts.Length != 2) throw new ArgumentException("host:port is expected", "value"); int port; if (!Int32.TryParse(parts[1], out port)) throw new ArgumentException("Cannot parse port: " + parts[1], "value"); return ResolveToEndPoint(parts[0], port); }
using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; using System.Net.Http; using System.Net.Http.Headers; using System.Web.Http; using System.Web.Http.Controllers; using System.Web.Http.Description; using PowerBIRestDemo.Areas.HelpPage.ModelDescriptions; using PowerBIRestDemo.Areas.HelpPage.Models; private static bool IsBindableWithTypeConverter(Type parameterType) { if (parameterType == null) { return false; } return TypeDescriptor.GetConverter(parameterType).CanConvertFrom(typeof(string)); }
public by cghersi 276 1 5 0
Retrieve BLOB From Azure Blob Storage
public static Dictionary<Guid, byte[]> GetBlobs(List<string> names) { Dictionary<string, byte[]> result = new Dictionary<string, byte[]>(); // retrieve info about the interesting BLOBs: IEnumerable<CloudBlob> blobs = s_defaultContainer.ListBlobs(). OfType<CloudBlob>().Where(c => names.Contains(c.Name)); // loop over the retrieved BLOBs: foreach (CloudBlob b in blobs) { b.FetchAttributes(); //otherwise we cannot query for Properties... byte[] res = new byte[b.Properties.Length]; // download the actual content: b.DownloadToByteArray(res, 0); result.Add(b.Name, res); } return result; }
public by marksimon232 2780 1 6 4
Most efficient way to perform a FullText Search on SQL MS Azure
SQL Azure Database does not currently (August 2014) support Full Text Search. Many requiring this functionality have opted to use Lucene.NET instead. There's a useful overview of Lucene.NET plus code samples below: Lucene.NET Overview and Code Samples: http://leoncullens.nl/post/2012/11/18/Full-Text-Search-on-Azure-with-LuceneNET.aspx I was able to create a working demo against one of my own SQL Azure tables in about 10 minutes. var indexWriter = new IndexWriter(azureDir, new StandardAnalyzer(Version.LUCENE_30), true, IndexWriter.MaxFieldLength.UNLIMITED);
public by Geometry 45179 0 4 0
Main: The main entry point for the application.
using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); }
var storageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["AzureWebJobsStorage"].ToString()); var blobClient = storageAccount.CreateCloudBlobClient(); var logContainer = blobClient.GetContainerReference("data"); if (logContainer.CreateIfNotExists()) { logContainer.SetPermissions(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Blob }); } CloudBlockBlob logfile = logContainer.GetBlockBlobReference("linkchecklogfiles/results.html"); logfile.Properties.ContentType = "text/html"; logfile.UploadFromFile("outputdata.html", FileMode.Open);
using Newtonsoft.Json.Linq; using System; using System.Globalization; using System.IO; using System.Net; using System.Text; using System.Web; static DateTime ParseTwitterDateTime(string p) { if (p == null) return DateTime.Now; p = p.Replace("+0000 ", ""); DateTimeOffset result; if (DateTimeOffset.TryParseExact(p, "ddd MMM dd HH:mm:ss yyyy", CultureInfo.GetCultureInfo("en-us").DateTimeFormat, DateTimeStyles.AssumeUniversal, out result)) return result.DateTime; else return DateTime.Now; }
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; using System.Reflection; [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity", Justification = "These are simple type factories and cannot be split up.")] private static Dictionary<Type, Func<long, object>> InitializeGenerators() { return new Dictionary<Type, Func<long, object>> { { typeof(Boolean), index => true }, { typeof(Byte), index => (Byte)64 }, { typeof(Char), index => (Char)65 }, { typeof(DateTime), index => DateTime.Now }, { typeof(DateTimeOffset), index => new DateTimeOffset(DateTime.Now) }, { typeof(DBNull), index => DBNull.Value }, { typeof(Decimal), index => (Decimal)index }, { typeof(Double), index => (Double)(index + 0.1) }, { typeof(Guid), index => Guid.NewGuid() }, { typeof(Int16), index => (Int16)(index % Int16.MaxValue) }, { typeof(Int32), index => (Int32)(index % Int32.MaxValue) }, { typeof(Int64), index => (Int64)index }, { typeof(Object), index => new object() }, { typeof(SByte), index => (SByte)64 }, { typeof(Single), index => (Single)(index + 0.1) }, { typeof(String), index => { return String.Format(CultureInfo.CurrentCulture, "sample string {0}", index); } }, { typeof(TimeSpan), index => { return TimeSpan.FromTicks(1234567); } }, { typeof(UInt16), index => (UInt16)(index % UInt16.MaxValue) }, { typeof(UInt32), index => (UInt32)(index % UInt32.MaxValue) }, { typeof(UInt64), index => (UInt64)index }, { typeof(Uri), index => { return new Uri(String.Format(CultureInfo.CurrentCulture, "http://webapihelppage{0}.com", index)); } }, }; }
using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; using System.Net.Http; using System.Net.Http.Headers; using System.Web.Http; using System.Web.Http.Controllers; using System.Web.Http.Description; using PowerBIRestDemo.Areas.HelpPage.ModelDescriptions; using PowerBIRestDemo.Areas.HelpPage.Models; private static void GenerateRequestModelDescription(HelpPageApiModel apiModel, ModelDescriptionGenerator modelGenerator, HelpPageSampleGenerator sampleGenerator) { ApiDescription apiDescription = apiModel.ApiDescription; foreach (ApiParameterDescription apiParameter in apiDescription.ParameterDescriptions) { if (apiParameter.Source == ApiParameterSource.FromBody) { Type parameterType = apiParameter.ParameterDescriptor.ParameterType; apiModel.RequestModelDescription = modelGenerator.GetOrCreateModelDescription(parameterType); apiModel.RequestDocumentation = apiParameter.Documentation; } else if (apiParameter.ParameterDescriptor != null && apiParameter.ParameterDescriptor.ParameterType == typeof(HttpRequestMessage)) { Type parameterType = sampleGenerator.ResolveHttpRequestMessageType(apiDescription); if (parameterType != null) { apiModel.RequestModelDescription = modelGenerator.GetOrCreateModelDescription(parameterType); } } } }