private async Task ApplyContext(HostAssignmentContext assignmentContext)
        {
            _logger.LogInformation($"Applying {assignmentContext.Environment.Count} app setting(s)");
            assignmentContext.ApplyAppSettings(_environment);

            // We need to get the non-PlaceholderMode script Path so we can unzip to the correct location.
            // This asks the factory to skip the PlaceholderMode check when configuring options.
            var options = _optionsFactory.Create(ScriptApplicationHostOptionsSetup.SkipPlaceholder);
            RunFromPackageContext pkgContext = assignmentContext.GetRunFromPkgContext();

            if ((pkgContext.IsScmRunFromPackage() && await pkgContext.BlobExistsAsync(_logger)) ||
                (!pkgContext.IsScmRunFromPackage() && !string.IsNullOrEmpty(pkgContext.Url) && pkgContext.Url != "1"))
            {
                await ApplyBlobPackageContext(pkgContext, options.ScriptPath);
            }
            else if (!string.IsNullOrEmpty(assignmentContext.AzureFilesConnectionString))
            {
                await MountCifs(assignmentContext.AzureFilesConnectionString, assignmentContext.AzureFilesContentShare, "/home");
            }

            // Irrespective of deployment mechanism mount the share for user data files.
            if (assignmentContext.IsUserDataMountEnabled())
            {
                if (!string.IsNullOrEmpty(assignmentContext.AzureFilesConnectionString) &&
                    !string.IsNullOrEmpty(assignmentContext.AzureFilesContentShare))
                {
                    await MountUserData(assignmentContext);
                }
                else
                {
                    _logger.LogWarning(
                        $"{EnvironmentSettingNames.AzureFilesConnectionString} or {EnvironmentSettingNames.AzureFilesContentShare} is empty. User data share will not be mounted");
                }
            }
        }
예제 #2
0
        public void Verifies_If_User_Data_Mount_Is_Enabled(string mountEnvVariable, bool isMountEnabled)
        {
            var hostAssignmentContext = new HostAssignmentContext {
                Environment = new Dictionary <string, string>()
            };

            if (mountEnvVariable != null)
            {
                hostAssignmentContext.Environment[EnvironmentSettingNames.UserDataMountEnabled] = mountEnvVariable;
            }

            Assert.Equal(isMountEnabled, hostAssignmentContext.IsUserDataMountEnabled());
        }