Kudu.Core.Environment.IsAzureEnvironment C# (CSharp) Method

IsAzureEnvironment() public static method

public static IsAzureEnvironment ( ) : bool
return bool
        public static bool IsAzureEnvironment()
        {
            return !String.IsNullOrEmpty(System.Environment.GetEnvironmentVariable("WEBSITE_INSTANCE_ID"));
        }

Usage Example

Esempio n. 1
0
        /// <summary>
        /// Sets the environment variables for Net Core CLI.
        /// </summary>
        /// <remarks>
        /// This method previously included environment variables to optimize net core runtime to run in a container.
        /// But they have been moved to the Kudu Dockerfile
        /// </remarks>>
        /// <param name="environment">
        /// IEnvironment object that maintains references to al the paths used by Kudu during runtime.
        /// </param>
        internal static void EnsureDotNetCoreEnvironmentVariable(IEnvironment environment)
        {
            if (Environment.IsAzureEnvironment())
            {
                // On Azure, restore nuget packages to d:\home\.nuget so they're persistent. It also helps
                // work around https://github.com/projectkudu/kudu/issues/2056.
                // Note that this only applies to project.json scenarios (not packages.config)
                SetEnvironmentVariableIfNotYetSet("NUGET_PACKAGES", Path.Combine(environment.RootPath, ".nuget"));

                // Set the telemetry environment variable
                SetEnvironmentVariableIfNotYetSet("DOTNET_CLI_TELEMETRY_PROFILE", "AzureKudu");
            }
            else
            {
                // Set it slightly differently if outside of Azure to differentiate
                SetEnvironmentVariableIfNotYetSet("DOTNET_CLI_TELEMETRY_PROFILE", "Kudu");
            }
        }