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
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 @@ -31,6 +31,9 @@ public class PowerShellFileProvisionerTests
31
31
private const string PSGalleryEmptyFeedResourceFileName =
32
32
"Microsoft.Azure.WebJobs.Script.Tests.Resources.FileProvisioning.PowerShell.PSGalleryEmptyFeed.xml" ;
33
33
34
+ private const string ProfileFileResourceFileName =
35
+ "Microsoft.Azure.WebJobs.Script.Tests.Resources.FileProvisioning.PowerShell.profile.ps1" ;
36
+
34
37
private readonly string _scriptRootPath ;
35
38
private readonly ILoggerFactory _loggerFactory = new LoggerFactory ( ) ;
36
39
private readonly TestLoggerProvider _loggerProvider = new TestLoggerProvider ( ) ;
@@ -57,6 +60,10 @@ public async Task AugmentFiles_Test()
57
60
string expectedContent = FileUtility . ReadResourceString ( RequirementsPsd1PSGalleryOnlineResourceFileName ) ;
58
61
Assert . Equal ( expectedContent , requirementsContent , StringComparer . OrdinalIgnoreCase ) ;
59
62
63
+ string profileContent = File . ReadAllText ( Path . Combine ( _scriptRootPath , ProfilePs1FileName ) ) ;
64
+ string expectedProfileContent = FileUtility . ReadResourceString ( ProfileFileResourceFileName ) ;
65
+ Assert . Equal ( expectedProfileContent , profileContent , StringComparer . OrdinalIgnoreCase ) ;
66
+
60
67
ValidateLogs ( _loggerProvider , _scriptRootPath ) ;
61
68
}
62
69
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
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 107
107
<None Remove =" Resources\FileProvisioning\PowerShell\PSGallerySampleFeed.xml" />
108
108
<None Remove =" Resources\FileProvisioning\PowerShell\requirements_PSGalleryOffline.psd1" />
109
109
<None Remove =" Resources\FileProvisioning\PowerShell\requirements_PSGalleryOnline.psd1" />
110
+ <None Remove =" Resources\FileProvisioning\PowerShell\profile.ps1" />
110
111
</ItemGroup >
111
112
112
113
<ItemGroup >
113
114
<EmbeddedResource Include =" Resources\FileProvisioning\PowerShell\PSGallerySampleFeed.xml" />
114
115
<EmbeddedResource Include =" Resources\FileProvisioning\PowerShell\PSGalleryEmptyFeed.xml" />
115
116
<EmbeddedResource Include =" Resources\FileProvisioning\PowerShell\requirements_PSGalleryOffline.psd1" />
116
- <EmbeddedResource Include =" Resources\FileProvisioning\PowerShell\requirements_PSGalleryOnline.psd1" >
117
+ <EmbeddedResource Include =" Resources\FileProvisioning\PowerShell\requirements_PSGalleryOnline.psd1" />
118
+ <EmbeddedResource Include =" Resources\FileProvisioning\PowerShell\profile.ps1" >
117
119
<CopyToOutputDirectory >Never</CopyToOutputDirectory >
118
120
</EmbeddedResource >
119
121
</ItemGroup >
You can’t perform that action at this time.
0 commit comments