File tree Expand file tree Collapse file tree 4 files changed +37
-4
lines changed
src/WebJobs.Script/FileProvisioning/PowerShell
test/WebJobs.Script.Tests
Resources/FileProvisioning/PowerShell Expand file tree Collapse file tree 4 files changed +37
-4
lines changed Original file line number Diff line number Diff line change 8
8
#
9
9
# You can define helper functions, run commands, or specify environment variables
10
10
# NOTE: any variables defined that are not environment variables will get reset after the first execution
11
+
11
12
# Authenticate with Azure PowerShell using MSI.
12
13
# Remove this if you are not planning on using MSI or Azure PowerShell.
13
-
14
- if ( $ env: MSI_SECRET -and ( Get-Module - ListAvailable Az.Accounts)) {
15
- Connect-AzAccount - Identity
14
+ if ( $ env: MSI_SECRET ) {
15
+ Disable-AzContextAutosave - Scope Process | Out-Null
16
+ Connect-AzAccount - Identity
16
17
}
17
18
18
19
# Uncomment the next line to enable legacy AzureRm alias in Azure PowerShell.
19
20
# Enable-AzureRmAlias
21
+
20
22
# You can also define functions or aliases that can be referenced in any of your PowerShell functions.
Original file line number Diff line number Diff line change @@ -32,6 +32,9 @@ public class PowerShellFileProvisionerTests
32
32
private const string PSGalleryEmptyFeedResourceFileName =
33
33
"Microsoft.Azure.WebJobs.Script.Tests.Resources.FileProvisioning.PowerShell.PSGalleryEmptyFeed.xml" ;
34
34
35
+ private const string ProfileFileResourceFileName =
36
+ "Microsoft.Azure.WebJobs.Script.Tests.Resources.FileProvisioning.PowerShell.profile.ps1" ;
37
+
35
38
private readonly string _scriptRootPath ;
36
39
private readonly ILoggerFactory _loggerFactory = new LoggerFactory ( ) ;
37
40
private readonly TestLoggerProvider _loggerProvider = new TestLoggerProvider ( ) ;
@@ -58,6 +61,10 @@ public async Task AugmentFiles_Test()
58
61
string expectedContent = FileUtility . ReadResourceString ( RequirementsPsd1PSGalleryOnlineResourceFileName ) ;
59
62
Assert . Equal ( expectedContent , requirementsContent , StringComparer . OrdinalIgnoreCase ) ;
60
63
64
+ string profileContent = File . ReadAllText ( Path . Combine ( _scriptRootPath , ProfilePs1FileName ) ) ;
65
+ string expectedProfileContent = FileUtility . ReadResourceString ( ProfileFileResourceFileName ) ;
66
+ Assert . Equal ( expectedProfileContent , profileContent , StringComparer . OrdinalIgnoreCase ) ;
67
+
61
68
ValidateLogs ( _loggerProvider , _scriptRootPath ) ;
62
69
}
63
70
Original file line number Diff line number Diff line change
1
+ # Azure Functions profile.ps1
2
+ #
3
+ # This profile.ps1 will get executed every "cold start" of your Function App.
4
+ # "cold start" occurs when:
5
+ #
6
+ # * A Function App starts up for the very first time
7
+ # * A Function App starts up after being de-allocated due to inactivity
8
+ #
9
+ # You can define helper functions, run commands, or specify environment variables
10
+ # NOTE: any variables defined that are not environment variables will get reset after the first execution
11
+
12
+ # Authenticate with Azure PowerShell using MSI.
13
+ # Remove this if you are not planning on using MSI or Azure PowerShell.
14
+ if ($env: MSI_SECRET ) {
15
+ Disable-AzContextAutosave - Scope Process | Out-Null
16
+ Connect-AzAccount - Identity
17
+ }
18
+
19
+ # Uncomment the next line to enable legacy AzureRm alias in Azure PowerShell.
20
+ # Enable-AzureRmAlias
21
+
22
+ # You can also define functions or aliases that can be referenced in any of your PowerShell functions.
Original file line number Diff line number Diff line change 109
109
<None Remove =" Resources\FileProvisioning\PowerShell\PSGallerySampleFeed.xml" />
110
110
<None Remove =" Resources\FileProvisioning\PowerShell\requirements_PSGalleryOffline.psd1" />
111
111
<None Remove =" Resources\FileProvisioning\PowerShell\requirements_PSGalleryOnline.psd1" />
112
+ <None Remove =" Resources\FileProvisioning\PowerShell\profile.ps1" />
112
113
</ItemGroup >
113
114
114
115
<ItemGroup >
115
116
<EmbeddedResource Include =" Resources\FileProvisioning\PowerShell\PSGallerySampleFeed.xml" />
116
117
<EmbeddedResource Include =" Resources\FileProvisioning\PowerShell\PSGalleryEmptyFeed.xml" />
117
118
<EmbeddedResource Include =" Resources\FileProvisioning\PowerShell\requirements_PSGalleryOffline.psd1" />
118
- <EmbeddedResource Include =" Resources\FileProvisioning\PowerShell\requirements_PSGalleryOnline.psd1" >
119
+ <EmbeddedResource Include =" Resources\FileProvisioning\PowerShell\requirements_PSGalleryOnline.psd1" />
120
+ <EmbeddedResource Include =" Resources\FileProvisioning\PowerShell\profile.ps1" >
119
121
<CopyToOutputDirectory >Never</CopyToOutputDirectory >
120
122
</EmbeddedResource >
121
123
</ItemGroup >
You can’t perform that action at this time.
0 commit comments