7
7
using System . Collections ;
8
8
using System . Collections . Generic ;
9
9
using System . Collections . ObjectModel ;
10
- using System . Text ;
11
10
12
11
using Microsoft . Azure . Functions . PowerShellWorker . Utility ;
13
12
using Microsoft . Azure . WebJobs . Script . Grpc . Messages ;
17
16
namespace Microsoft . Azure . Functions . PowerShellWorker . PowerShell
18
17
{
19
18
using System . Management . Automation ;
20
- using System . Reflection ;
21
19
22
20
internal class PowerShellManager
23
21
{
@@ -44,23 +42,25 @@ internal class PowerShellManager
44
42
45
43
public static PowerShellManager Create ( RpcLogger logger )
46
44
{
47
- // Set up initial session state: set execution policy, import helper module, and using namespace
45
+ // Set up initial session state
48
46
var initialSessionState = InitialSessionState . CreateDefault ( ) ;
49
47
if ( Platform . IsWindows )
50
48
{
51
49
initialSessionState . ExecutionPolicy = Microsoft . PowerShell . ExecutionPolicy . Unrestricted ;
52
50
}
53
51
var pwsh = PowerShell . Create ( initialSessionState ) ;
54
52
55
- // Add HttpResponseContext namespace so users can reference
56
- // HttpResponseContext without needing to specify the full namespace
57
- // and also import the Azure Functions binding helper module
53
+ // Build path to the Azure Functions binding helper module
58
54
string modulePath = System . IO . Path . Join (
59
55
AppDomain . CurrentDomain . BaseDirectory ,
60
56
"Azure.Functions.PowerShell.Worker.Module" ,
61
57
"Azure.Functions.PowerShell.Worker.Module.psd1" ) ;
58
+
59
+ // Add HttpResponseContext namespace so users can reference
60
+ // HttpResponseContext without needing to specify the full namespace
62
61
pwsh . AddScript ( $ "using namespace { typeof ( HttpResponseContext ) . Namespace } ")
63
62
. AddStatement ( )
63
+ // Import the Azure Functions binding helper module
64
64
. AddCommand ( "Import-Module" )
65
65
. AddParameter ( "Name" , modulePath )
66
66
. AddParameter ( "Scope" , "Global" )
@@ -83,7 +83,6 @@ public Hashtable InvokeFunction(
83
83
// If it does, we invoke the command of that name. We also need to fetch
84
84
// the ParameterMetadata so that we can tell whether or not the user is asking
85
85
// for the $TriggerMetadata
86
-
87
86
using ( ExecutionTimer . Start ( _logger , "Parameter metadata retrieved." ) )
88
87
{
89
88
if ( entryPoint != "" )
0 commit comments