def getServicePrincipalById()

in scenario-notebooks/UserSecurityMetadata/Entities.py [0:0]


    def getServicePrincipalById(objectId):
        rawoutput = executeProcess(
            f'az ad sp show --id {objectId} --query [displayName,objectId] --output tsv'.split(' '))
        output = rawoutput.split('\n')
        if len(output) != 2:
            raise Exception(
                f'Unable to get AAD ServicePrincipal with Id - {objectId}. Error - {rawoutput}')
        else:
            sp = ServicePrincipal(output[0], output[1])
            return sp