Skip to content

Commit 58924c8

Browse files
Stream handling, param block, PowerShellManager (#11)
* param block is back and fix multiple execution issue * reworked PowerShellExtension methods into a PowerShellManager object * move InitPowerShell into PowerShellManager * have all logging use correct index in collection * switch DataAdded to DataAdding * address Dongbo's feedback * new lines and fixed Set-ExecutionPolicy * made timer threadstatic and deleted StartupArgumentsTests * switch to ThreadStatic stopwatch * address Dongbo's feedback * remove messaging * added headers to a few files * Add new line to the end * change to Write-Information
1 parent 195a7b6 commit 58924c8

26 files changed

+411
-759
lines changed

azure-functions-powershell-worker.sln

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{8C758288-390
77
EndProject
88
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Functions.PowerShell.Worker", "src\Azure.Functions.PowerShell.Worker\Azure.Functions.PowerShell.Worker.csproj", "{939262BA-4823-405E-81CD-436C0B77D524}"
99
EndProject
10-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Functions.PowerShell.Worker.Messaging", "src\Azure.Functions.PowerShell.Worker.Messaging\Azure.Functions.PowerShell.Worker.Messaging.csproj", "{A1581262-DE79-4C01-AD6C-88BE7C3E6322}"
11-
EndProject
1210
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{12092936-4F2A-4B40-9AF2-56C840D44FEA}"
1311
EndProject
1412
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Functions.PowerShell.Worker.Test", "test\Azure.Functions.PowerShell.Worker.Test\Azure.Functions.PowerShell.Worker.Test.csproj", "{535C8DA3-479D-42BF-B1AF-5B03ECAF67A4}"
@@ -38,18 +36,6 @@ Global
3836
{939262BA-4823-405E-81CD-436C0B77D524}.Release|x64.Build.0 = Release|Any CPU
3937
{939262BA-4823-405E-81CD-436C0B77D524}.Release|x86.ActiveCfg = Release|Any CPU
4038
{939262BA-4823-405E-81CD-436C0B77D524}.Release|x86.Build.0 = Release|Any CPU
41-
{A1581262-DE79-4C01-AD6C-88BE7C3E6322}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
42-
{A1581262-DE79-4C01-AD6C-88BE7C3E6322}.Debug|Any CPU.Build.0 = Debug|Any CPU
43-
{A1581262-DE79-4C01-AD6C-88BE7C3E6322}.Debug|x64.ActiveCfg = Debug|Any CPU
44-
{A1581262-DE79-4C01-AD6C-88BE7C3E6322}.Debug|x64.Build.0 = Debug|Any CPU
45-
{A1581262-DE79-4C01-AD6C-88BE7C3E6322}.Debug|x86.ActiveCfg = Debug|Any CPU
46-
{A1581262-DE79-4C01-AD6C-88BE7C3E6322}.Debug|x86.Build.0 = Debug|Any CPU
47-
{A1581262-DE79-4C01-AD6C-88BE7C3E6322}.Release|Any CPU.ActiveCfg = Release|Any CPU
48-
{A1581262-DE79-4C01-AD6C-88BE7C3E6322}.Release|Any CPU.Build.0 = Release|Any CPU
49-
{A1581262-DE79-4C01-AD6C-88BE7C3E6322}.Release|x64.ActiveCfg = Release|Any CPU
50-
{A1581262-DE79-4C01-AD6C-88BE7C3E6322}.Release|x64.Build.0 = Release|Any CPU
51-
{A1581262-DE79-4C01-AD6C-88BE7C3E6322}.Release|x86.ActiveCfg = Release|Any CPU
52-
{A1581262-DE79-4C01-AD6C-88BE7C3E6322}.Release|x86.Build.0 = Release|Any CPU
5339
{535C8DA3-479D-42BF-B1AF-5B03ECAF67A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
5440
{535C8DA3-479D-42BF-B1AF-5B03ECAF67A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
5541
{535C8DA3-479D-42BF-B1AF-5B03ECAF67A4}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -65,7 +51,6 @@ Global
6551
EndGlobalSection
6652
GlobalSection(NestedProjects) = preSolution
6753
{939262BA-4823-405E-81CD-436C0B77D524} = {8C758288-3909-4CE1-972D-1BE966628D6C}
68-
{A1581262-DE79-4C01-AD6C-88BE7C3E6322} = {8C758288-3909-4CE1-972D-1BE966628D6C}
6954
{535C8DA3-479D-42BF-B1AF-5B03ECAF67A4} = {12092936-4F2A-4B40-9AF2-56C840D44FEA}
7055
EndGlobalSection
7156
EndGlobal

examples/PSCoreApp/MyHttpTrigger/run.ps1

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
1+
param($req, $TriggerMetadata)
2+
3+
# Write-Host $TriggerMetadata["Name"]
4+
5+
# Invoked with Invoke-RestMethod:
6+
# irm http://localhost:7071/api/MyHttpTrigger?Name=Tyler
7+
# Input bindings are added to the scope of the script: ex. `$req`
8+
9+
# If no name was passed by query parameter
110
$name = 'World'
11+
12+
# You can interact with query parameters, the body of the request, etc.
213
if($req.Query.Name) {
314
$name = $req.Query.Name
415
}
516

6-
Write-Verbose "Hello $name" -Verbose
17+
# you can write to the same streams as you would in a normal PowerShell script
18+
Write-Verbose "Verbose $name" -Verbose
719
Write-Warning "Warning $name"
820

21+
# items in the pipeline get logged
22+
$name
23+
24+
# You set the value of your output bindings by assignment `$nameOfOutputBinding = 'foo'`
925
$res = [HttpResponseContext]@{
1026
Body = @{ Hello = $name }
1127
ContentType = 'application/json'

src/Azure.Functions.PowerShell.Worker/Azure.Functions.PowerShell.Worker.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<TargetFramework>netcoreapp2.1</TargetFramework>
6-
76
<Product>Azure Function PowerShell Language Worker</Product>
87
<Company>Microsoft Corporation</Company>
98
<Copyright>(c) Microsoft Corporation. All rights reserved.</Copyright>
@@ -15,7 +14,6 @@
1514
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
1615
<NeutralLanguage>en-US</NeutralLanguage>
1716
</PropertyGroup>
18-
1917
<ItemGroup>
2018
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.1.1" />
2119
<PackageReference Include="Microsoft.PowerShell.SDK" Version="6.1.0-rc.1" />

src/Azure.Functions.PowerShell.Worker/Function/FunctionInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ public FunctionInfo(RpcFunctionMetadata metadata)
4040
}
4141
}
4242
}
43-
}
43+
}

src/Azure.Functions.PowerShell.Worker/Function/FunctionLoader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ internal class Function
3636
public FunctionInfo Info {get; internal set;}
3737
public string ScriptPath {get; internal set;}
3838
}
39-
}
39+
}

src/Azure.Functions.PowerShell.Worker/Http/HttpRequestContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@ public bool Equals(HttpRequestContext other)
6262
&& (RawBody == other.RawBody || RawBody.Equals(other.RawBody));
6363
}
6464
}
65-
}
65+
}

src/Azure.Functions.PowerShell.Worker/Http/HttpResponseContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@ public bool Equals(HttpResponseContext other)
6161
&& (Body == other.Body || Body.Equals(other.Body));
6262
}
6363
}
64-
}
64+
}

src/Azure.Functions.PowerShell.Worker/Messaging/RpcLogger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,4 @@ public void SetContext(string requestId, string invocationId)
7575
_invocationId = invocationId;
7676
}
7777
}
78-
}
78+
}

src/Azure.Functions.PowerShell.Worker/PowerShell/Host/AzureFunctionsHost.cs

Lines changed: 0 additions & 128 deletions
This file was deleted.

0 commit comments

Comments
 (0)