コード例 #1
0
        private void UpdateEnvironmentVariables(IDictionary <string, string> secrets)
        {
            foreach (var secret in secrets)
            {
                if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable(secret.Key)))
                {
                    ColoredConsole.WriteLine(WarningColor($"Skipping '{secret.Key}' from local settings as it's already defined in current environment variables."));
                }
                else if (!string.IsNullOrEmpty(secret.Value))
                {
                    ColoredConsole.WriteLine(DarkGray($".NET Setting {secret.Key} = {secret.Value}"));
                    Environment.SetEnvironmentVariable(secret.Key, secret.Value, EnvironmentVariableTarget.Process);
                }
                else if (secret.Value == string.Empty)
                {
                    ColoredConsole.WriteLine(DarkGray($"Windows Setting {secret.Key} = {secret.Value}"));
                    EnvironmentNativeMethods.SetEnvironmentVariable(secret.Key, secret.Value);
                }
                else
                {
                    ColoredConsole.WriteLine(WarningColor($"Skipping '{secret.Key}' because value is null"));
                }
            }

            if (EnabledFunctions != null && EnabledFunctions.Count > 0)
            {
                for (var i = 0; i < EnabledFunctions.Count; i++)
                {
                    Environment.SetEnvironmentVariable($"AzureFunctionsJobHost__functions__{i}", EnabledFunctions[i]);
                }
            }
        }
コード例 #2
0
 static void GetDiskFreeSpace(string path, out ulong freeBytes, out ulong totalBytes)
 {
     ulong diskFreeBytes;
     if (!EnvironmentNativeMethods.GetDiskFreeSpaceEx(path, out freeBytes, out totalBytes, out diskFreeBytes))
     {
         throw new Win32Exception();
     }
 }