AL/Get-AppJsonForProjectAndRepo.ps1

<#
 .Synopsis
  Gets the app.json for a project
 .Description
  Gets the app.json for a project from DevOps
 .Parameter devOpsOrganization
  Path to DevOps organization
 .Parameter devOpsProjectName
  Name of the project that contains the app.json
 .Parameter devOpsToken
  Token to access Azure DevOps. Can be provided in settings.json
 .Parameter RepositoryName
  Name of the repository that contains the app.json
 .Parameter Publisher
  Name of the publisher of the project
 .Parameter BranchName
  Name of the branch within the project
 .Example
  Get-AppJsonForProjectAndRepo
#>

function Get-AppJsonForProjectAndRepo {
    Param(
        [Parameter(Mandatory=$true)]
        [string] $devOpsOrganization,
        [Parameter(Mandatory=$true)]
        [string]$devOpsProjectName,
        [Parameter(Mandatory=$true)]
        [string] $devOpsToken,
        [Parameter(Mandatory=$false)]
        [string]$RepositoryName,
        [Parameter(Mandatory=$false)]
        [string]$Publisher,
        [Parameter(Mandatory=$false)]
        [string]$BranchName = "master"
    )
    if ($Publisher -eq 'Microsoft') {
        return '{}'
    }

    $devOpsProjectName = (Get-DevOpsProjectList -devOpsOrganization $devOpsOrganization -devOpsToken $devOpsToken | Where-Object name -like ('*{0}*' -f $devOpsProjectName)).name

    if ($null -eq $RepositoryName -or $RepositoryName -eq '') {
        $RepositoryName = $devOpsProjectName
    }

    $AppContent = Invoke-AzureDevOpsApi ('https://dev.azure.com/{0}/{1}/_apis/git/repositories/{2}/items?recursionLevel=full&scopePath=app.json&version={3}' -f $devOpsOrganization, $devOpsProjectName, (Get-RepositoryId -devOpsOrganization $devOpsOrganization -devOpsProjectName $devOpsProjectName -RepositoryName $RepositoryName -devOpsToken $devOpsToken), $BranchName) -devOpsToken $devOpsToken -GetContents
    $AppJson = ConvertFrom-Json $AppContent
    $AppJson
}