Ejemplo n.º 1
0
        private void ConfigureProbingPaths(ExtensionBundleOptions options)
        {
            if (_environment.IsAppServiceWindowsEnvironment())
            {
                string windowsDefaultPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86),
                                                         ScriptConstants.DefaultExtensionBundleDirectory,
                                                         options.Id);

                options.ProbingPaths.Add(windowsDefaultPath);
            }

            var homeDirectory = _environment.GetEnvironmentVariable(EnvironmentSettingNames.AzureWebsiteHomePath);

            if ((_environment.IsLinuxAppServiceEnvironment() ||
                 _environment.IsLinuxContainerEnvironment() ||
                 _environment.IsContainerEnvironment()) &&
                !string.IsNullOrEmpty(homeDirectory))
            {
                string linuxDefaultPath            = Path.Combine(Path.GetPathRoot(homeDirectory), ScriptConstants.DefaultExtensionBundleDirectory, options.Id);
                string deploymentPackageBundlePath = Path.Combine(
                    homeDirectory,
                    "site", "wwwroot", ".azureFunctions", ScriptConstants.ExtensionBundleDirectory, options.Id);

                options.ProbingPaths.Add(linuxDefaultPath);
                options.ProbingPaths.Add(deploymentPackageBundlePath);
            }
        }
        public void Configure(ExtensionBundleOptions options)
        {
            IConfigurationSection jobHostSection = _configuration.GetSection(ConfigurationSectionNames.JobHost);
            var extensionBundleSection           = jobHostSection.GetSection(ConfigurationSectionNames.ExtensionBundle);

            if (extensionBundleSection.Exists())
            {
                extensionBundleSection.Bind(options);
                ValidateBundleId(options.Id);
                ConfigureBundleVersion(extensionBundleSection, options);

                if (_environment.IsAppServiceEnvironment())
                {
                    options.DownloadPath = Path.Combine(_environment.GetEnvironmentVariable(EnvironmentSettingNames.AzureWebsiteHomePath),
                                                        "data", "Functions", ScriptConstants.ExtensionBundleDirectory, options.Id);
                    ConfigureProbingPaths(options);
                }
            }
        }
Ejemplo n.º 3
0
        public void Configure(ExtensionBundleOptions options)
        {
            IConfigurationSection jobHostSection = _configuration.GetSection(ConfigurationSectionNames.JobHost);
            var extensionBundleSection           = jobHostSection.GetSection(ConfigurationSectionNames.ExtensionBundle);

            if (extensionBundleSection.Exists())
            {
                ConfigureBundleVersion(extensionBundleSection, options);
                extensionBundleSection.Bind(options);
                ValidateBundleId(options.Id);

                string homeDirectory = _environment.GetEnvironmentVariable(EnvironmentSettingNames.AzureWebsiteHomePath);
                if ((_environment.IsAppService() ||
                     _environment.IsLinuxConsumption() ||
                     _environment.IsContainer()) &&
                    !string.IsNullOrEmpty(homeDirectory))
                {
                    options.DownloadPath = Path.Combine(homeDirectory, "data", "Functions", ScriptConstants.ExtensionBundleDirectory, options.Id);
                    ConfigureProbingPaths(options);
                }
            }
        }
Ejemplo n.º 4
0
        private void ConfigureBundleVersion(IConfigurationSection configurationSection, ExtensionBundleOptions options)
        {
            string bundleVersion = configurationSection.GetValue <string>("version");

            if (string.IsNullOrWhiteSpace(bundleVersion) || !VersionRange.TryParse(bundleVersion.ToString(), allowFloating: true, out VersionRange version))
            {
                string message = string.Format(Resources.ExtensionBundleConfigMissingVersion, ScriptConstants.HostMetadataFileName);
                throw new ArgumentException(message);
            }
            options.Version = version;
        }