Deploy to azure functions using powershell

前端 未结 5 2167
一生所求
一生所求 2021-02-07 10:20

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

5条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-07 10:53

    In addition to what Chris describes, there is a first class ARM API you can use to deploy functions. Here is what it looks like in PowerShell:

    Function DeployHttpTriggerFunction($ResourceGroupName, $SiteName, $FunctionName, $CodeFile, $TestData)
    {
        $FileContent = "$(Get-Content -Path $CodeFile -Raw)"
    
        $props = @{
            config = @{
                bindings = @(
                    @{
                        type = "httpTrigger"
                        direction = "in"
                        webHookType = ""
                        name = "req"
                    }
                    @{
                        type = "http"
                        direction = "out"
                        name = "res"
                    }
                )
            }
            files = @{
                "index.js" = $FileContent
            }
            test_data = $TestData
        }
    
        New-AzureRmResource -ResourceGroupName $ResourceGroupName -ResourceType Microsoft.Web/sites/functions -ResourceName $SiteName/$FunctionName -PropertyObject $props -ApiVersion 2015-08-01 -Force
    }
    

    See https://github.com/projectkudu/kudu/wiki/Functions-API for information about the underlying API.

提交回复
热议问题