public static string GetTargetFrameworkJsonContents(string content) { try { var document = JObject.Parse(content); string targetFramework = (string)document["frameworks"].First.ToString() .Replace("\"", "") .Replace(":", "") .Replace("{", "") .Replace("}", "") .Trim(); if (String.IsNullOrEmpty(targetFramework)) { // old-style .csproj return(string.Empty); } else { KuduEventSource.Log.GenericEvent( ServerConfiguration.GetApplicationName(), string.Format("Dotnet target framework found: {0}", targetFramework), string.Empty, string.Empty, string.Empty, string.Empty); return(targetFramework); } } catch (Exception) { return(string.Empty); } }
public static string GetTargetFrameworkContents(string content) { try { XDocument document = XDocument.Parse(content); var targetFramework = document.Root.Descendants("TargetFramework"); var targetFrameworkElement = targetFramework.FirstOrDefault(); if (targetFrameworkElement == null || targetFrameworkElement.Value == null) { // old-style .csproj return(string.Empty); } else { KuduEventSource.Log.GenericEvent( ServerConfiguration.GetApplicationName(), string.Format("Dotnet target framework found: {0}", targetFramework), string.Empty, string.Empty, string.Empty, string.Empty); return(targetFrameworkElement.Value); } } catch (Exception) { return(string.Empty); } }
public static void CriticalExecute(string method, Action action) { try { action(); } catch (Exception ex) { KuduEventSource.Log.KuduException( ServerConfiguration.GetApplicationName(), method, string.Empty, string.Empty, "Critical execution encounters an exception and will fail fast in 60s", ex.ToString()); ThreadPool.QueueUserWorkItem(_ => { Thread.Sleep(60000); System.Environment.FailFast($"Method {method} encounters critical exception {ex}"); }); throw; } }
public static void SniffGlobalJson(String path) { try { if (File.Exists(path)) { String json = File.ReadAllText(path); string version = SniffGlobalJsonContents(json); if (!String.IsNullOrEmpty(version)) { KuduEventSource.Log.GenericEvent( ServerConfiguration.GetApplicationName(), string.Format("global.json found, pinned sdk version {0}", version), string.Empty, string.Empty, string.Empty, string.Empty); } } } catch { // no op } }
public static string GenerateFunctionToken() { string siteName = ServerConfiguration.GetApplicationName(); string issuer = $"https://{siteName}.scm.azurewebsites.net"; string audience = $"https://{siteName}.azurewebsites.net/azurefunctions"; return(JwtGenerator.GenerateToken(issuer, audience, expires: DateTime.UtcNow.AddMinutes(2))); }
public static string GetTargetFrameworkContents(string content) { try { XDocument document = XDocument.Parse(content); var targetFramework = document.Root.Descendants("TargetFramework"); var targetFrameworkElement = targetFramework.FirstOrDefault(); if (targetFrameworkElement != null && targetFrameworkElement.Value != null) { KuduEventSource.Log.GenericEvent( ServerConfiguration.GetApplicationName(), string.Format("Dotnet target framework found: {0}", targetFrameworkElement.Value), string.Empty, string.Empty, string.Empty, string.Empty); return(targetFrameworkElement.Value); } var targetFrameworks = document.Root.Descendants("TargetFrameworks"); var targetFrameworksElement = targetFrameworks.FirstOrDefault(); if (targetFrameworksElement != null && targetFrameworksElement.Value != null) { KuduEventSource.Log.GenericEvent( ServerConfiguration.GetApplicationName(), string.Format("Multiple Dotnet target frameworks found: {0}. Using First", targetFrameworksElement.Value), string.Empty, string.Empty, string.Empty, string.Empty); return(targetFrameworksElement.Value.Split(';').First()); } // old-style .csproj return(string.Empty); } catch (Exception) { return(string.Empty); } }