Is there any way, I can deploy to azure functions using powershell scripts? CI will not work for us because we use octopus deploy to deploy to all of our production services. So it would be beneficial if there is a way to deploy using powershell scripts.
Thanks!
In the Azure portal, browse to your function app. Under Settings, choose Configuration. In the General settings tab, locate the PowerShell version. Choose your desired PowerShell Core version and select Save.
In this article you create a function app and related Azure resources. In Solution Explorer, right-click the project and select Publish. In Target, select Azure then Next. Select Azure Function App (Windows) for the Specific target, which creates a function app that runs on Windows, and then select Next.
You can deploy functions to Azure using the Kudu REST API. You can also see some code/samples of doing this in our templates repository. In this code sample, you can see how our test script calls out to the Kudu Rest apis to deploy a zip to the Function App.
The folder structure for functions is a function per folder. You need to deploy your Function folders to ./site/wwwroot
on the Function App. You also need to add any app settings which might contain your secrets if you add any new bindings between updates.
The PowerShell code would look something along the lines of:
$apiUrl = $config.scmEndpoint + "/api/zip/"
if ($destinationPath)
{
$apiUrl = $apiUrl + $destinationPath
}
$response = Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization=("Basic {0}" -f $config.authInfo)} -Method PUT -InFile $zipFilePath -ContentType "multipart/form-data"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With