Skip to content
This repository has been archived by the owner on Dec 22, 2022. It is now read-only.

Rabobank-Archive/azure-functions

Repository files navigation

build codecov stryker

Azure DevOps Compliance - Azure Functions

Here is the home of the azure functions that evaluate projects in your Azure DevOps organization.

Deploy the latest release

shell:

export azdev_token=
export azdev_organization=
export extension_secret=
export extension_name=azure-devops-compliance
export extension_publisher=riezebosch

export rg=
export name=

az group create --name $rg --location westeurope
az storage account create -g $rg -n $name

function=$(az functionapp create -g $rg -n $name -s $name --consumption-plan-location westeurope --os-type windows --runtime dotnet --functions-version 3 -o tsv --query "id")
az ad sp create-for-rbac --name $name --role contributor --scopes $function --sdk-auth

az functionapp cors add -a https://$extension_publisher.gallerycdn.vsassets.io -n $name -g $rg
az functionapp config appsettings set --name $name --resource-group $rg --settings TOKEN=$azdev_token ORGANIZATION=$azdev_organization
az functionapp config appsettings set --name $name --resource-group $rg --settings EXTENSION_NAME=$extension_name EXTENSION_PUBLISHER=$extension_publisher EXTENSION_SECRET=$extension_secret  

curl https://github.com/azure-devops-compliance/azure-functions/releases/latest/download/release.zip -L --output release.zip
az functionapp deployment source config-zip -g $rg -n $name --src release.zip

powershell:

function Install-AzDevComplianceFunction {
    Param(
        [Parameter(Mandatory=$true)][String] $azdev_token,
        [Parameter(Mandatory=$true)][String] $azdev_organization,
        [Parameter(Mandatory=$true)][String] $extension_secret,
        [Parameter(Mandatory=$false)][String] $extension_name = "azure-devops-compliance",
        [Parameter(Mandatory=$false)][String] $extension_publisher= "riezebosch",
        
        [Parameter(Mandatory=$true)][String] $rg,
        [Parameter(Mandatory=$true)][String] $name
    )

    az group create --name $rg --location westeurope
    az storage account create -g $rg -n $name
    
    $function = az functionapp create -g $rg -n $name -s $name --consumption-plan-location westeurope --os-type windows --runtime dotnet --functions-version 3 -o tsv --query "id"
    az ad sp create-for-rbac --name $name --role contributor --scopes $function --sdk-auth
    
    az functionapp cors add -a https://$extension_publisher.gallerycdn.vsassets.io -n $name -g $rg
    az functionapp config appsettings set --name $name --resource-group $rg --settings TOKEN=$azdev_token ORGANIZATION=$azdev_organization
    az functionapp config appsettings set --name $name --resource-group $rg --settings EXTENSION_NAME=$extension_name EXTENSION_PUBLISHER=$extension_publisher EXTENSION_SECRET=$extension_secret  

    iwr https://github.com/azure-devops-compliance/azure-functions/releases/latest/download/release.zip -OutFile release.zip
    az functionapp deployment source config-zip -g $rg -n $name --src release.zip
}

Drop this function into your terminal and invoke it with the mandatory parameters afterwards.