Zip deployment for Azure Functions

1
2
CURL Command
curl -k -X POST -u $pythonfuncapptestRG --data-binary @"C:\YourPath\pythoncode.zip" https://pythonfuncapptestrg.scm.yourdomain.com/api/zipdeploy

Powershell command:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Avoiding SSL Warning for invalid certificate
##############################################
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
##############################################
# Force TLs 1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

$username = "`$pythonfuncapptestRG"
$password = "YourPassword"
$filePath = "C:\YourPath\pythoncode.zip"
$apiUrl = "https://pythonfuncapptestrg.scm.yourdomain.com/api/zipdeploy"
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $password)))
$userAgent = "powershell/1.0"
Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -UserAgent $userAgent -Method POST -InFile $filePath -ContentType "application/x-www-form-urlencoded" -Verbose -Debug

For more information:
Zip deployment for Azure Functions
https://docs.microsoft.com/en-us/azure/azure-functions/deployment-zip-push

HTH. 2019-11-5 By Jacky