public void ProfileShouldWork() { //initialize fresh log _testLogger.FullLog.Clear(); var funcLoadReq = _functionLoadRequest.Clone(); funcLoadReq.Metadata.Directory = Path.Join(_functionDirectory, "ProfileBasic", "Func1"); try { FunctionLoader.SetupWellKnownPaths(funcLoadReq); _testManager.PerformRunspaceLevelInitialization(); Assert.Single(_testLogger.FullLog); Assert.Equal("Information: INFORMATION: Hello PROFILE", _testLogger.FullLog[0]); } finally { FunctionLoader.SetupWellKnownPaths(_functionLoadRequest); } }
/// <summary> /// Method to process a FunctionLoadRequest. /// FunctionLoadRequest should be processed sequentially. There is no point to process FunctionLoadRequest /// concurrently as a FunctionApp doesn't include a lot functions in general. Having this step sequential /// will make the Runspace-level initialization easier and more predictable. /// </summary> internal StreamingMessage ProcessFunctionLoadRequest(StreamingMessage request) { FunctionLoadRequest functionLoadRequest = request.FunctionLoadRequest; StreamingMessage response = NewStreamingMessageTemplate( request.RequestId, StreamingMessage.ContentOneofCase.FunctionLoadResponse, out StatusResult status); response.FunctionLoadResponse.FunctionId = functionLoadRequest.FunctionId; try { // Ideally, the initialization should happen when processing 'WorkerInitRequest', however, the 'WorkerInitRequest' // message doesn't provide the file path of the FunctionApp. That information is not available until the first // 'FunctionLoadRequest' comes in. Therefore, we run initialization here. if (!_isFunctionAppInitialized) { FunctionLoader.SetupWellKnownPaths(functionLoadRequest); _powerShellManager.PerformWorkerLevelInitialization(); _powerShellManager.PerformRunspaceLevelInitialization(); _isFunctionAppInitialized = true; } // Load the metadata of the function. _functionLoader.LoadFunction(functionLoadRequest); } catch (Exception e) { status.Status = StatusResult.Types.Status.Failure; status.Exception = e.ToRpcException(); } return(response); }