o365 graph login --authType password --userName $(username) --password $(password)

#try to get app with manifest id
$catalogApps = o365 graph teams app list -o json | ConvertFrom-Json
$existingApp = $catalogApps | Where-Object {$_.externalId -eq "$(TeamsManifestId)" }

if($existingApp){
    #app already exists so update it.
    #id used to update is the one returned from the graph teams app list call
    o365 graph teams app update --id $existingApp.id --filePath "$(System.DefaultWorkingDirectory)/_spfxteamsdevops-CI/drop/teams/SPFxTeamsManifest.zip"
}
else{
    #app does not exist so add it.
    o365 graph teams app publish --filePath "$(System.DefaultWorkingDirectory)/_spfxteamsdevops-CI/drop/teams/SPFxTeamsManifest.zip"
}