Skip to content

Commit 6458ff2

Browse files
Upgrading Azure Function Building logic
1 parent b44387b commit 6458ff2

File tree

8 files changed

+32
-42
lines changed

8 files changed

+32
-42
lines changed

templates/PSFProject/PSMDTemplate.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@{
22
TemplateName = 'PSFProject'
3-
Version = "1.2.1.0"
3+
Version = "1.3.1.0"
44
AutoIncrementVersion = $true
55
Tags = 'module','psframework'
66
Author = 'Friedrich Weinmann'
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"version": "2.0",
3+
"managedDependency": {
4+
"Enabled": true
5+
}
6+
}

templates/PSFProject/azFunctionResources/profile.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ Use this to create a common execution environment,
55
but keep in mind that the profile execution time is added to the function startup time for ALL functions.
66
#>
77

8-
Set-PSFConfig -FullName 'AutogeneratedAzureFunction.Function.StatusCode' -Value ([System.Net.HttpStatusCode]::OK)
8+
if ($env:MSI_SECRET -and (Get-Module -ListAvailable Az.Accounts))
9+
{
10+
Connect-AzAccount -Identity
11+
}

templates/PSFProject/azFunctionResources/profileFunctions/Set-AzureFunctionStatus.ps1

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

templates/PSFProject/azFunctionResources/profileFunctions/Write-AzureFunctionOutput.ps1

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,17 @@
3838
$Serialize,
3939

4040
[System.Net.HttpStatusCode]
41-
$Status
41+
$Status = [System.Net.HttpStatusCode]::OK
4242
)
4343

44-
if ($PSBoundParameters.ContainsKey('Status'))
45-
{
46-
Set-AzureFunctionStatus -Status $Status
47-
}
48-
4944
if ($Serialize)
5045
{
5146
$Value = $Value | ConvertTo-PSFClixml
5247
}
5348

5449
Push-OutputBinding -Name Response -Value (
5550
[HttpResponseContext]@{
56-
StatusCode = (Get-PSFConfigValue -FullName 'AutogeneratedAzureFunction.Function.StatusCode' -Fallback ([System.Net.HttpStatusCode]::OK))
51+
StatusCode = $Status
5752
Body = $Value
5853
}
5954
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@{
2+
Az = '1.*'
3+
}

templates/PSFProject/build/vsts-build.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ if (-not $WorkingDirectory)
3434

3535
# Prepare publish folder
3636
Write-PSFMessage -Level Important -Message "Creating and populating publishing directory"
37-
$publishDir = New-Item -Path $WorkingDirectory -Name publish -ItemType Directory
37+
$publishDir = New-Item -Path $WorkingDirectory -Name publish -ItemType Directory -Force
3838
Copy-Item -Path "$($WorkingDirectory)\þnameþ" -Destination $publishDir.FullName -Recurse -Force
3939

4040
#region Gather text data to compile

templates/PSFProject/build/vsts-packageFunction.ps1

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11

22
<#
33
.SYNOPSIS
4-
Packages a Azure Functions project, ready to release.
4+
Packages an Azure Functions project, ready to release.
55
66
.DESCRIPTION
7-
Packages a Azure Functions project, ready to release.
7+
Packages an Azure Functions project, ready to release.
88
Should be part of the release pipeline, after ensuring validation.
99
1010
Look into the 'AzureFunctionRest' template for generating functions for the module if you do.
@@ -18,7 +18,10 @@
1818
param (
1919
$WorkingDirectory = "$($env:SYSTEM_DEFAULTWORKINGDIRECTORY)\_þnameþ",
2020

21-
$Repository = 'PSGallery'
21+
$Repository = 'PSGallery',
22+
23+
[switch]
24+
$IncludeAZ
2225
)
2326

2427
$moduleName = 'þnameþ'
@@ -115,7 +118,15 @@ foreach ($functionSourceFile in (Get-ChildItem -Path "$($moduleRoot)\$moduleName
115118

116119
# Transfer common files
117120
Write-PSFMessage -Level Host -Message "Transfering core function data"
118-
Copy-Item -Path "$($WorkingDirectory)\azFunctionResources\host.json" -Destination "$($workingroot.FullName)\"
121+
if ($IncludeAZ)
122+
{
123+
Copy-Item -Path "$($WorkingDirectory)\azFunctionResources\host-az.json" -Destination "$($workingroot.FullName)\host.json"
124+
Copy-Item -Path "$($WorkingDirectory)\azFunctionResources\requirements.psd1" -Destination "$($workingroot.FullName)\"
125+
}
126+
else
127+
{
128+
Copy-Item -Path "$($WorkingDirectory)\azFunctionResources\host.json" -Destination "$($workingroot.FullName)\"
129+
}
119130
Copy-Item -Path "$($WorkingDirectory)\azFunctionResources\local.settings.json" -Destination "$($workingroot.FullName)\"
120131

121132
# Build the profile file

0 commit comments

Comments
 (0)