public static void LogAutorestGeneratedJsonIfExists(string rootScriptPath, ILogger logger) { string autorestGeneratedJsonPath = Path.Combine(rootScriptPath, ScriptConstants.AutorestGeenratedMetadataFileName); JObject autorestGeneratedJson; if (FileUtility.FileExists(autorestGeneratedJsonPath)) { string autorestGeneratedJsonPathContents = FileUtility.ReadAllText(autorestGeneratedJsonPath); try { autorestGeneratedJson = JObject.Parse(autorestGeneratedJsonPathContents); logger.AutorestGeneratedFunctionApplication(autorestGeneratedJson.ToString()); } catch (JsonException ex) { logger.IncorrectAutorestGeneratedJsonFile($"Unable to parse autorest configuration file '{autorestGeneratedJsonPath}'" + $" with content '{autorestGeneratedJsonPathContents}' | exception: {ex.StackTrace}"); } catch (Exception ex) { logger.IncorrectAutorestGeneratedJsonFile($"Caught exception while parsing .autorest_generated.json | " + $"exception: {ex.StackTrace}"); } } // If we dont find the .autorest_generated.json in the function app, we just don't log anything. }
public static async Task MarkContainerDisabled(ILogger logger) { logger.LogDebug("Setting container instance offline"); var disableContainerFilePath = Path.Combine(Path.GetTempPath(), ScriptConstants.DisableContainerFileName); if (!FileUtility.FileExists(disableContainerFilePath)) { await FileUtility.WriteAsync(disableContainerFilePath, "This container instance is offline"); } }
public static bool CheckAppOffline(string scriptPath) { // check if we should be in an offline state string offlineFilePath = Path.Combine(scriptPath, ScriptConstants.AppOfflineFileName); if (FileUtility.FileExists(offlineFilePath)) { return(true); } return(false); }
public static bool CheckAppOffline(IEnvironment environment, string scriptPath) { // Linux container environments have an additional way of putting a specific worker instance offline. if (environment.IsLinuxConsumptionContainerDisabled()) { return(true); } // check if we should be in an offline state string offlineFilePath = Path.Combine(scriptPath, ScriptConstants.AppOfflineFileName); if (FileUtility.FileExists(offlineFilePath)) { return(true); } return(false); }
public static bool IsContainerDisabled() { return(FileUtility.FileExists(Path.Combine(Path.GetTempPath(), ScriptConstants.DisableContainerFileName))); }