Notitie
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen u aan te melden of de directory te wijzigen.
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen de mappen te wijzigen.
Warning
Azure Communication Services voert ingrijpende wijzigingen door en sommige services worden uitgefaseerd. Lees meer in de gids voor pensioen- en veranderingen.
Communication Services-SDK's en REST API's gebruiken het id-type om te bepalen wie met wie communiceert. Id's geven bijvoorbeeld op wie u wilt bellen of wie een chatbericht heeft verzonden.
Afhankelijk van de context worden id's verpakt met extra eigenschappen, zoals in de ChatParticipant Chat-SDK of in de RemoteParticipant Aanroepende SDK.
In dit artikel worden verschillende typen id's beschreven en hoe deze eruitzien in programmeertalen. U krijgt ook tips over het gebruik ervan.
Het CommunicationIdentifier type
Er zijn gebruikersidentiteiten die u zelf maakt en er zijn externe identiteiten. Microsoft Teams-gebruikers en telefoonnummers zijn externe identiteiten die tot uiting komen in interoperabiliteitsscenario's. Elk van deze verschillende identiteitstypen heeft een bijbehorende id die deze vertegenwoordigt. Een id is een gestructureerd type dat typeveiligheid biedt en goed werkt met de voltooiing van de code van uw editor.
Communicatiegebruiker
De CommunicationUserIdentifier interface vertegenwoordigt een gebruikersidentiteit die is gemaakt met behulp van de Identity SDK of REST API. Dit is de enige id die wordt gebruikt als uw toepassing geen gebruik maakt van microsoft Teams-interoperabiliteits- of telefoniefuncties.
Basaal gebruik
// at some point you will have created a new user identity in your trusted service
const newUser = await identityClient.createUser();
// and then send newUser.communicationUserId down to your client application
// where you can again create an identifier for the user
const sameUser = { communicationUserId: newUserId };
API-verwijzing
Microsoft Teams-gebruiker
De MicrosoftTeamsUserIdentifier-interface vertegenwoordigt een Teams-gebruiker met zijn Microsoft Entra-gebruikersobject-ID. U kunt de object-id van Microsoft Entra-gebruikers ophalen via de Microsoft Graph REST API/gebruikerseindpunt van de id eigenschap in het antwoord. Zie Graph Explorer en bekijk de Graph SDK voor meer informatie over het werken met Microsoft Graph. U kunt de id ook vinden als claim oid in een Microsoft Entra-token of Microsoft Entra-toegangstoken nadat uw gebruiker zich heeft aangemeld en een token heeft verkregen.
Basaal gebruik
// get the Teams user's ID from Graph APIs if only the email is known
const user = await graphClient.api("/users/bob@contoso.com").get();
// create an identifier
const teamsUser = { microsoftTeamsUserId: user.id };
// if you're not operating in the public cloud, you must also pass the right Cloud type.
const gcchTeamsUser = { microsoftTeamsUserId: userId, cloud: "gcch" };
API-verwijzing
Telefoonnummer
De PhoneNumberIdentifier interface vertegenwoordigt een telefoonnummer. De service gaat ervan uit dat telefoonnummers zijn opgemaakt in E.164-indeling.
Basaal gebruik
// create an identifier
const phoneNumber = { phoneNumber: "+112345556789" };
API-verwijzing
Microsoft Teams-toepassing
De MicrosoftTeamsAppIdentifier interface vertegenwoordigt een bot van de Teams Voice-toepassingen zoals Oproepwachtrij en Auto Attendant met de object-id van de Microsoft Entra-bot. De Teams-toepassingen moeten worden geconfigureerd met een resourceaccount. U kunt de object-id van de Microsoft Entra-bot ophalen via de Microsoft Graph REST API/gebruikerseindpunt van de id eigenschap in het antwoord. Zie Graph Explorer en bekijk de Graph SDK voor meer informatie over het werken met Microsoft Graph.
Basaal gebruik
// Get the Microsoft Teams App's ID from Graph APIs
const users = await graphClient.api("/users")
.filter(filterConditions)
.select('displayName,id')
.get();
//Here we assume that you have a function getBotFromUsers that gets the bot from the returned response
const bot = getBotFromUsers(users);
// Create an identifier
const teamsAppIdentifier = { teamsAppId: bot.id };
// If you're not operating in the public cloud, you must also pass the right Cloud type.
const gcchTeamsAppIdentifier = { teamsAppId: id, cloud: "gcch" };
API-verwijzing
Teams-extensiegebruiker
De TeamsExtensionUserIdentifier interface vertegenwoordigt een Teams-gebruiker die is ingeschakeld voor de uitbreidbaarheid van Teams-telefoons. A TeamsExtensionUserIdentifier vereist de Microsoft Entra-gebruikersobject-id van de Teams-gebruiker, de Tenant-id van Microsoft Entra waar de gebruiker zich bevindt en de Resource-id van Azure Communication Services. U kunt de Microsoft Entra-gebruikersobject-id ophalen via de Microsoft Graph REST API /users endpoint van de id eigenschap in de response, en de Microsoft Entra-tenant-id via de Microsoft Graph REST API /organization endpoint van de id eigenschap in de response. Zie Graph Explorer en bekijk de Graph SDK voor meer informatie over het werken met Microsoft Graph.
U kunt de object-id ook vinden als de oid claim en de tenant-id als de tid claim in een Microsoft Entra-token of Microsoft Entra-toegangstoken nadat uw gebruiker zich heeft aangemeld en een token heeft verkregen.
Basaal gebruik
// get the Teams user's ID from Graph APIs if only the email is known
const user = await graphClient.api("/users/bob@contoso.com").get();
// Get the tenantId from Graph API
const org = await graphClient.api("/organization").get();
const tenantId = org.value[0].id;
//Communication Services Resource ID
const resourceId = "<resource-id-guid>";
// create an identifier
const teamsExtensionUser = { userId: user.id, tenantId: tenantId, resourceId: resourceId };
// if you're not operating in the public cloud, you must also pass the right Cloud type.
const gcchTeamsExtensionUser = { userId: user.id, tenantId: tenantId, resourceId: resourceId, cloud: "gcch" };
API-verwijzing
Onbekend
De UnknownIdentifier interface bestaat voor toekomstbestendig maken en u kunt deze tegenkomen wanneer u een oude versie van de SDK gebruikt en er onlangs een nieuw id-type wordt geïntroduceerd. Een onbekende identifier van de service wordt gedeserialiseerd als UnknownIdentifier in de SDK.
Basaal gebruik
// create an identifier
const unknownId = { id: "a raw id that originated in the service" };
API-verwijzing
Hoe de basisinterface CommunicationIdentifier te verwerken
Terwijl u id's maakt voor een concreet type dat u in de SDK doorgeeft, retourneert de SDK een CommunicationIdentifierKind, wat een gediscrimineerde samenvoeging is. Het is eenvoudig om te beperken tot een concreet type en we raden een switch-case-instructie aan met patroonkoppeling:
switch (communicationIdentifier.kind)
{
case "communicationUser":
// TypeScript has narrowed communicationIdentifier to be a CommunicationUserKind
console.log(`Communication user: ${communicationIdentifier.communicationUserId}`);
break;
case "microsoftTeamsUser":
// narrowed to MicrosoftTeamsUserKind
console.log(`Teams user: ${communicationIdentifier.microsoftTeamsUserId}`);
break;
case "microsoftTeamsApp":
// narrowed to MicrosoftTeamsAppIdentifier
console.log(`Teams app: ${communicationIdentifier.teamsAppId}`);
break;
case "phoneNumber":
// narrowed to PhoneNumberKind
console.log(`Phone number: ${communicationIdentifier.phoneNumber}`);
break;
case "unknown":
// narrowed to UnknownIdentifierKind
console.log(`Unknown: ${communicationIdentifier.id}`);
break;
default:
// be careful here whether you want to throw because a new SDK version
// can introduce new identifier types
break;
}
De id-interfaces zijn zodanig ontworpen dat u kind niet hoeft te specificeren om de overvloed aan informatie te verminderen. Bovendien wordt de discriminerende samenvoeging met de kind eigenschap alleen gebruikt wanneer deze wordt geretourneerd door de SDK. Als u echter een id moet vertalen naar het bijbehorende discriminerende samenvoegtype, kunt u deze helper gebruiken:
const identifierKind = getIdentifierKind(identifier); // now you can switch-case on the kind
Onbewerkte id-weergave
Soms moet u een id serialiseren naar een platte tekenreeks. Als u bijvoorbeeld de id wilt opslaan in een databasetabel of als u deze wilt gebruiken als URL-parameter.
Voor dat doel hebben id's een andere weergave met de naam RawId. Een id kan altijd worden omgezet in de bijbehorende onbewerkte id en een geldige onbewerkte id kan altijd worden geconverteerd naar een id.
Omdat azure-communication-common@2.1.0 de SDK helpt bij de conversie:
// get an identifier's raw Id
const rawId = getIdentifierRawId(communicationIdentifier);
// create an identifier from a given raw Id
const identifier = createIdentifierFromRawId(rawId);
Een ongeldige onbewerkte id wordt geconverteerd naar UnknownIdentifier in de SDK en elke validatie vindt alleen plaats aan de servicezijde.
Communicatiegebruiker
De CommunicationUserIdentifier vertegenwoordigt een gebruikersidentiteit die is gemaakt met behulp van de Identity SDK of REST API. Dit is de enige id die wordt gebruikt als uw toepassing geen gebruik maakt van microsoft Teams-interoperabiliteits- of telefoniefuncties.
Basaal gebruik
// at some point you will have created a new user identity in your trusted service
CommunicationUserIdentifier newUser = await identityClient.CreateUser();
// and then send newUser.Id down to your client application
// where you can again create an identifier for the user
var sameUser = new CommunicationUserIdentifier(newUserId);
API-verwijzing
Microsoft Teams-gebruiker
De MicrosoftTeamsUserIdentifier vertegenwoordigt een Teams-gebruiker met de microsoft Entra-gebruikersobject-id. U kunt de object-id van Microsoft Entra-gebruikers ophalen via de Microsoft Graph REST API/gebruikerseindpunt van de id eigenschap in het antwoord. Zie Graph Explorer en bekijk de Graph SDK voor meer informatie over het werken met Microsoft Graph. U kunt de id ook vinden als de oid claim in een Microsoft Entra-token of Microsoft Entra-toegangstoken nadat u zich hebt aangemeld en een token hebt verkregen.
Basaal gebruik
// get the Teams user's ID from Graph APIs if only the email is known
var user = await graphClient.Users["bob@contoso.com"]
.Request()
.GetAsync();
// create an identifier
var teamsUser = new MicrosoftTeamsUserIdentifier(user.Id);
// if you're not operating in the public cloud, you must also pass the right Cloud type.
var gcchTeamsUser = new MicrosoftTeamsUserIdentifier(userId: userId, cloud: CommunicationCloudEnvironment.Gcch);
API-verwijzing
Telefoonnummer
Het PhoneNumberIdentifier vertegenwoordigt een telefoonnummer. De service gaat ervan uit dat telefoonnummers zijn opgemaakt in E.164-indeling.
Basaal gebruik
// create an identifier
var phoneNumber = new PhoneNumberIdentifier("+112345556789");
API-verwijzing
Microsoft Teams-toepassing
De MicrosoftTeamsAppIdentifier interface vertegenwoordigt een bot van de Teams Voice-toepassingen zoals Oproepwachtrij en Auto Attendant met de object-id van de Microsoft Entra-bot. De Teams-toepassingen moeten worden geconfigureerd met een resourceaccount. U kunt de object-id van de Microsoft Entra-bot ophalen via de Microsoft Graph REST API/gebruikerseindpunt van de id eigenschap in het antwoord. Zie Graph Explorer en bekijk de Graph SDK voor meer informatie over het werken met Microsoft Graph.
Basaal gebruik
// Get the Microsoft Teams App's ID from Graph APIs
var users = await graphClient.Users.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Select = new string []{ "displayName","id" };
requestConfiguration.QueryParameters.Filter = filterConditions;
});
// Here we assume that you have a function GetBotFromUsers that gets the bot from the returned response
var bot = GetBotFromUsers(users);
// Create an identifier
var teamsAppIdentifier = new MicrosoftTeamsAppIdentifier(bot.Id);
// If you're not operating in the public cloud, you must also pass the right Cloud type.
var gcchTeamsAppIdentifier = new MicrosoftTeamsAppIdentifier(bot.Id, CommunicationCloudEnvironment.Gcch);
API-verwijzing
Teams-extensiegebruiker
De TeamsExtensionUserIdentifier interface vertegenwoordigt een Teams-gebruiker die is ingeschakeld voor de uitbreidbaarheid van Teams-telefoons. A TeamsExtensionUserIdentifier vereist de Microsoft Entra-gebruikersobject-id van de Teams-gebruiker, de Tenant-id van Microsoft Entra waar de gebruiker zich bevindt en de Resource-id van Azure Communication Services. U kunt de Microsoft Entra-gebruikersobject-id ophalen via de Microsoft Graph REST API /users endpoint van de id eigenschap in de response, en de Microsoft Entra-tenant-id via de Microsoft Graph REST API /organization endpoint van de id eigenschap in de response. Zie Graph Explorer en bekijk de Graph SDK voor meer informatie over het werken met Microsoft Graph.
U kunt de object-id ook vinden als de oid claim en de tenant-id als de tid claim in een Microsoft Entra-token of Microsoft Entra-toegangstoken nadat uw gebruiker zich heeft aangemeld en een token heeft verkregen.
Basaal gebruik
// get the Teams user's ID from Graph APIs if only the email is known
var user = await graphClient.Users["bob@contoso.com"]
.Request()
.GetAsync();
// Get the tenantId from Graph API
var organization = await graphClient.Organization
.Request()
.GetAsync();
string tenantId = organization.CurrentPage.FirstOrDefault()?.Id;
//Communication Services Resource ID
var resourceId = "<resource-id-guid>";
// create an identifier
var teamsExtensionUser = new TeamsExtensionUserIdentifier(user.Id, tenantId, resourceId);
// if you're not operating in the public cloud, you must also pass the right Cloud type.
var gcchTeamsExtensionUser = new TeamsExtensionUserIdentifier(userId: user.Id, tenantId: tenantId, resourceId: resourceId, cloud: CommunicationCloudEnvironment.Gcch);
API-verwijzing
Onbekend
Het UnknownIdentifier bestaat voor toekomstbestendig maken en u kunt deze tegenkomen wanneer u een oude versie van de SDK gebruikt en er onlangs een nieuw id-type wordt geïntroduceerd. Een onbekende identifier van de service wordt gedeserialiseerd als UnknownIdentifier in de SDK.
Basaal gebruik
// create an identifier
var unknown = new UnknownIdentifier("a raw id that originated in the service");
API-verwijzing
Hoe je de basisklasse CommunicationIdentifier afhandelt
Terwijl u id's maakt voor een concreet type dat u in de SDK doorgeeft, retourneert de SDK het CommunicationIdentifier protocol. Het is eenvoudig om down te casten naar een specifiek type en we raden een switch-case-instructie aan met pattern matching:
switch (communicationIdentifier)
{
case CommunicationUserIdentifier communicationUser:
Console.WriteLine($"Communication user: {communicationUser.Id}");
break;
case MicrosoftTeamsUserIdentifier teamsUser:
Console.WriteLine($"Teams user: {teamsUser.UserId}");
break;
case MicrosoftTeamsAppIdentifier teamsApp:
Console.WriteLine($"Teams app: {teamsApp.AppId}");
break;
case PhoneNumberIdentifier phoneNumber:
Console.WriteLine($"Phone number: {phoneNumber.PhoneNumber}");
break;
case UnknownIdentifier unknown:
Console.WriteLine($"Unknown: {unknown.Id}");
break;
default:
// be careful here whether you want to throw because a new SDK version
// can introduce new identifier types
break;
}
Onbewerkte id-weergave
Soms moet u een id serialiseren naar een platte tekenreeks. Als u bijvoorbeeld de id wilt opslaan in een databasetabel of als u deze wilt gebruiken als URL-parameter.
Voor dat doel hebben id's een andere weergave met de naam RawId. Een id kan altijd worden omgezet in de bijbehorende onbewerkte id en een geldige onbewerkte id kan altijd worden geconverteerd naar een id.
Omdat Azure.Communication.Common 1.2.0 de SDK helpt bij de conversie:
// get an identifier's raw Id
string rawId = communicationIdentifier.RawId;
// create an identifier from a given raw Id
CommunicationIdentifier identifier = CommunicationIdentifier.FromRawId(rawId);
Een ongeldige onbewerkte id wordt geconverteerd naar UnknownIdentifier in de SDK en elke validatie vindt alleen plaats aan de servicezijde.
Communicatiegebruiker
De CommunicationUserIdentifier vertegenwoordigt een gebruikersidentiteit die is gemaakt met behulp van de Identity SDK of REST API. Dit is de enige id die wordt gebruikt als uw toepassing geen gebruik maakt van microsoft Teams-interoperabiliteits- of telefoniefuncties.
Basaal gebruik
# at some point you will have created a new user identity in your trusted service
new_user = identity_client.create_user()
# and then send new_user.properties['id'] down to your client application
# where you can again create an identifier for the user
same_user = CommunicationUserIdentifier(new_user_id)
API-verwijzing
Microsoft Teams-gebruiker
De MicrosoftTeamsUserIdentifier vertegenwoordigt een Teams-gebruiker met de microsoft Entra-gebruikersobject-id. U kunt de object-id van Microsoft Entra-gebruikers ophalen via de Microsoft Graph REST API/gebruikerseindpunt van de id eigenschap in het antwoord. Zie Graph Explorer en bekijk de Graph SDK voor meer informatie over het werken met Microsoft Graph. U kunt de id ook vinden als de oid claim in een Microsoft Entra-token of Microsoft Entra-toegangstoken nadat u zich hebt aangemeld en een token hebt verkregen.
Basaal gebruik
# get the Teams user's ID from Graph APIs if only the email is known
user_id = graph_client.get("/users/bob@contoso.com").json().get("id");
# create an identifier
teams_user = MicrosoftTeamsUserIdentifier(user_id)
# if you're not operating in the public cloud, you must also pass the right Cloud type.
gcch_teams_user = MicrosoftTeamsUserIdentifier(user_id, cloud=CommunicationCloudEnvironment.GCCH)
API-verwijzing
Telefoonnummer
Het PhoneNumberIdentifier vertegenwoordigt een telefoonnummer. De service gaat ervan uit dat telefoonnummers zijn opgemaakt in E.164-indeling.
Basaal gebruik
# create an identifier
phone_number = PhoneNumberIdentifier("+112345556789")
API-verwijzing
Microsoft Teams-toepassing
De MicrosoftTeamsAppIdentifier interface vertegenwoordigt een bot van de Teams Voice-toepassingen zoals Oproepwachtrij en Auto Attendant met de object-id van de Microsoft Entra-bot. De Teams-toepassingen moeten worden geconfigureerd met een resourceaccount. U kunt de object-id van de Microsoft Entra-bot ophalen via de Microsoft Graph REST API/gebruikerseindpunt van de id eigenschap in het antwoord. Zie Graph Explorer en bekijk de Graph SDK voor meer informatie over het werken met Microsoft Graph.
Basaal gebruik
# Get the Microsoft Teams App's ID from Graph APIs
users = graph_client.get("/users").json()
# Here we assume that you have a function get_bot_from_users that gets the bot from the returned response
bot = get_bot_from_users(users);
# Create an identifier
teams_app_identifier = MicrosoftTeamsAppIdentifier(app_id=bot.get("id"))
# If you're not operating in the public cloud, you must also pass the right Cloud type.
gcch_teams_app_identifier = MicrosoftTeamsAppIdentifier(
app_id=bot.get("id"),
cloud=CommunicationCloudEnvironment.GCCH
)
API-verwijzing
Teams-extensiegebruiker
De TeamsExtensionUserIdentifier interface vertegenwoordigt een Teams-gebruiker die is ingeschakeld voor de uitbreidbaarheid van Teams-telefoons. A TeamsExtensionUserIdentifier vereist de Microsoft Entra-gebruikersobject-id van de Teams-gebruiker, de Tenant-id van Microsoft Entra waar de gebruiker zich bevindt en de Resource-id van Azure Communication Services. U kunt de Microsoft Entra-gebruikersobject-id ophalen via de Microsoft Graph REST API /users endpoint van de id eigenschap in de response, en de Microsoft Entra-tenant-id via de Microsoft Graph REST API /organization endpoint van de id eigenschap in de response. Zie Graph Explorer en bekijk de Graph SDK voor meer informatie over het werken met Microsoft Graph.
U kunt de object-id ook vinden als de oid claim en de tenant-id als de tid claim in een Microsoft Entra-token of Microsoft Entra-toegangstoken nadat uw gebruiker zich heeft aangemeld en een token heeft verkregen.
Basaal gebruik
# get the Teams user's ID from Graph APIs if only the email is known
user_id = graph_client.get("/users/bob@contoso.com").json().get("id");
# get the tenantId from Graph API
tenant_id = graph_client.get("/organization").json()["value"][0]["id"]
# Communication Services Resource ID
resourceId = "<resource-id-guid>"
# create an identifier
teams_user = TeamsExtensionUserIdentifier(user_id, tenant_id, resource_id)
# if you're not operating in the public cloud, you must also pass the right Cloud type
gcch_teams_user = TeamsExtensionUserIdentifier(user_id, tenant_id, resource_id, cloud=CommunicationCloudEnvironment.GCCH)
API-verwijzing
Onbekend
Het UnknownIdentifier bestaat voor toekomstbestendig maken en u kunt deze tegenkomen wanneer u een oude versie van de SDK gebruikt en er onlangs een nieuw id-type wordt geïntroduceerd. Een onbekende id van de service wordt gedeserialiseerd naar de UnknownIdentifier SDK.
Basaal gebruik
# create an identifier
unknown = UnknownIdentifier("a raw id that originated in the service")
API-verwijzing
Hoe je de basisklasse CommunicationIdentifier afhandelt
Terwijl u id's maakt voor een concreet type dat u in de SDK doorgeeft, retourneert de SDK het CommunicationIdentifier protocol. Concrete identifierklassen zijn het CommunicationIdentifier-protocol en een getypte woordenlijst genaamd properties. U kunt dus patroonkoppeling gebruiken voor de exemplaarvariabele van kind het protocol om te vertalen naar het concrete type:
match communication_identifier.kind:
case CommunicationIdentifierKind.COMMUNICATION_USER:
print(f"Communication user: {communication_identifier.properties['id']}")
case CommunicationIdentifierKind.MICROSOFT_TEAMS_USER:
print(f"Teams user: {communication_identifier.properties['user_id']}")
case CommunicationIdentifierKind.MICROSOFT_TEAMS_APP:
print(f"Teams app: {communication_identifier.properties['app_id']}")
case CommunicationIdentifierKind.PHONE_NUMBER:
print(f"Phone number: {communication_identifier.properties['value']}")
case CommunicationIdentifierKind.UNKNOWN:
print(f"Unknown: {communication_identifier.raw_id}")
case _:
# be careful here whether you want to throw because a new SDK version
# can introduce new identifier types
Onbewerkte id-weergave
Soms moet u een id serialiseren naar een platte tekenreeks. Als u bijvoorbeeld de id wilt opslaan in een databasetabel of als u deze wilt gebruiken als URL-parameter.
Voor dat doel hebben id's een andere weergave met de naam RawId. Een id kan altijd worden omgezet in de bijbehorende onbewerkte id en een geldige onbewerkte id kan altijd worden geconverteerd naar een id.
De SDK helpt bij de conversie:
# get an identifier's raw Id
raw_id = communication_identifier.raw_id
# create an identifier from a given raw Id
identifier = identifier_from_raw_id(raw_id)
Een ongeldige onbewerkte id wordt geconverteerd naar UnknownIdentifier in de SDK en elke validatie vindt alleen plaats aan de servicezijde.
Communicatiegebruiker
De CommunicationUserIdentifier vertegenwoordigt een gebruikersidentiteit die is gemaakt met behulp van de Identity SDK of REST API. Dit is de enige id die wordt gebruikt als uw toepassing geen gebruik maakt van microsoft Teams-interoperabiliteits- of telefoniefuncties.
Basaal gebruik
// at some point you will have created a new user identity in your trusted service
CommunicationUserIdentifier newUser = identityClient.CreateUser();
// and then send newUser.getId() down to your client application
// where you can again create an identifier for the user
var sameUser = new CommunicationUserIdentifier(newUserId);
API-verwijzing
Microsoft Teams-gebruiker
De MicrosoftTeamsUserIdentifier vertegenwoordigt een Teams-gebruiker met de microsoft Entra-gebruikersobject-id. U kunt de object-id van Microsoft Entra-gebruikers ophalen via de Microsoft Graph REST API/gebruikerseindpunt van de id eigenschap in het antwoord. Zie Graph Explorer en bekijk de Graph SDK voor meer informatie over het werken met Microsoft Graph. U kunt de id ook vinden als claim oid in een Microsoft Entra-token of Microsoft Entra-toegangstoken nadat uw gebruiker zich heeft aangemeld en een token heeft verkregen.
Basaal gebruik
// get the Teams user's ID from Graph APIs if only the email is known
var user = graphClient.users("bob@contoso.com")
.buildRequest()
.get();
// create an identifier
var teamsUser = new MicrosoftTeamsUserIdentifier(user.id);
// if you're not operating in the public cloud, you must also set the right Cloud type.
var gcchTeamsUser = new MicrosoftTeamsUserIdentifier(userId).setCloudEnvironment(CommunicationCloudEnvironment.GCCH);
API-verwijzing
Telefoonnummer
Het PhoneNumberIdentifier vertegenwoordigt een telefoonnummer. De service gaat ervan uit dat telefoonnummers zijn opgemaakt in E.164-indeling.
Basaal gebruik
// create an identifier
var phoneNumber = new PhoneNumberIdentifier("+112345556789");
API-verwijzing
Microsoft Teams-toepassing
De MicrosoftTeamsAppIdentifier interface vertegenwoordigt een bot van de Teams Voice-toepassingen zoals Oproepwachtrij en Auto Attendant met de object-id van de Microsoft Entra-bot. De Teams-toepassingen moeten worden geconfigureerd met een resourceaccount. U kunt de object-id van de Microsoft Entra-bot ophalen via de Microsoft Graph REST API/gebruikerseindpunt van de id eigenschap in het antwoord. Zie Graph Explorer en bekijk de Graph SDK voor meer informatie over het werken met Microsoft Graph.
Basaal gebruik
// Get the Microsoft Teams App's ID from Graph APIs
var user = graphClient.users()
.buildRequest()
.filter(filterConditions)
.select("displayName,id")
.get();
//Here we assume that you have a function getBotFromUsers that gets the bot from the returned response
var bot = getBotFromUsers(users);
// Create an identifier
var teamsAppIdentifier = new MicrosoftTeamsAppIdentifier(bot.id);
// If you're not operating in the public cloud, you must also pass the right Cloud type.
var gcchTeamsAppIdentifier = new MicrosoftTeamsAppIdentifier(bot.id, CommunicationCloudEnvironment.GCCH);
API-verwijzing
Teams-extensiegebruiker
De TeamsExtensionUserIdentifier interface vertegenwoordigt een Teams-gebruiker die is ingeschakeld voor de uitbreidbaarheid van Teams-telefoons. A TeamsExtensionUserIdentifier vereist de Microsoft Entra-gebruikersobject-id van de Teams-gebruiker, de Tenant-id van Microsoft Entra waar de gebruiker zich bevindt en de Resource-id van Azure Communication Services. U kunt de Microsoft Entra-gebruikersobject-id ophalen via de Microsoft Graph REST API /users endpoint van de id eigenschap in de response, en de Microsoft Entra-tenant-id via de Microsoft Graph REST API /organization endpoint van de id eigenschap in de response. Zie Graph Explorer en bekijk de Graph SDK voor meer informatie over het werken met Microsoft Graph.
U kunt de object-id ook vinden als de oid claim en de tenant-id als de tid claim in een Microsoft Entra-token of Microsoft Entra-toegangstoken nadat uw gebruiker zich heeft aangemeld en een token heeft verkregen.
Basaal gebruik
// get the Teams user's ID from Graph APIs if only the email is known
var user = graphClient.users("bob@contoso.com")
.buildRequest()
.get();
// get the tenantId from Graph API
OrganizationCollectionPage organizations = graphClient.organization()
.buildRequest()
.get();
String tenantId = organizations.getCurrentPage().get(0).id;
// Communication Services Resource ID
var resourceId = "<resource-id-guid>";
// create an identifier
var teamsExtensionUser = new TeamsExtensionUserIdentifier(user.id, tenantId, resourceId);
// if you're not operating in the public cloud, you must also set the right Cloud type.
var gcchTeamsExtensionUser = new TeamsExtensionUserIdentifier(user.id, tenantId, resourceId).setCloudEnvironment(CommunicationCloudEnvironment.GCCH);
API-verwijzing
Onbekend
Het UnknownIdentifier bestaat voor toekomstbestendig maken en u kunt deze tegenkomen wanneer u een oude versie van de SDK gebruikt en er onlangs een nieuw id-type wordt geïntroduceerd. Een onbekende identifier van de service wordt gedeserialiseerd als UnknownIdentifier in de SDK.
Basaal gebruik
// create an identifier
var unknown = new UnknownIdentifier("a raw id that originated in the service");
API-verwijzing
Hoe je de basisklasse CommunicationIdentifier afhandelt
Terwijl u identificatoren maakt voor een concreet type dat u aan de SDK doorgeeft, retourneert de SDK de abstractie. U kunt terug casten naar een betontype:
if (communicationIdentifier instanceof CommunicationUserIdentifier) {
System.out.println("Communication user: " + ((CommunicationUserIdentifier)communicationIdentifier).getId());
}
else if (communicationIdentifier instanceof MicrosoftTeamsUserIdentifier) {
System.out.println("Teams user: " + ((MicrosoftTeamsUserIdentifier)communicationIdentifier).getUserId());
}
else if (communicationIdentifier instanceof MicrosoftTeamsAppIdentifier) {
Log.i(tag, "Teams app: " + (( MicrosoftTeamsAppIdentifier)communicationIdentifier).getAppId());
}
else if (communicationIdentifier instanceof PhoneNumberIdentifier) {
System.out.println("Phone number: " + ((PhoneNumberIdentifier)communicationIdentifier).getPhoneNumber());
}
else if (communicationIdentifier instanceof UnknownIdentifier) {
System.out.println("Unknown user: " + ((UnknownIdentifier)communicationIdentifier).getId());
}
else {
// be careful here whether you want to throw because a new SDK version
// can introduce new identifier types
}
Onbewerkte id-weergave
Soms moet u een id serialiseren naar een platte tekenreeks. Als u bijvoorbeeld de id wilt opslaan in een databasetabel of als u deze wilt gebruiken als URL-parameter.
Voor dat doel hebben id's een andere weergave met de naam RawId. Een id kan altijd worden omgezet in de bijbehorende onbewerkte id en een geldige onbewerkte id kan altijd worden geconverteerd naar een id.
Omdat azure-communication-common 1.2.0 de SDK helpt bij de conversie:
// get an identifier's raw Id
String rawId = communicationIdentifier.getRawId();
// create an identifier from a given raw Id
CommunicationIdentifier identifier = CommunicationIdentifier.fromRawId(rawId);
Een ongeldige onbewerkte id wordt geconverteerd naar UnknownIdentifier in de SDK en elke validatie vindt alleen plaats aan de servicezijde.
Communicatiegebruiker
De CommunicationUserIdentifier vertegenwoordigt een gebruikersidentiteit die is gemaakt met behulp van de Identity SDK of REST API. Dit is de enige id die wordt gebruikt als uw toepassing geen gebruik maakt van microsoft Teams-interoperabiliteits- of telefoniefuncties.
Basaal gebruik
// at some point you will have created a new user identity in your trusted service
// and send the new user id down to your client application
// where you can create an identifier for the user
let user = CommunicationUserIdentifier(newUserId)
API-verwijzing
Microsoft Teams-gebruiker
De MicrosoftTeamsUserIdentifier vertegenwoordigt een Teams-gebruiker met de microsoft Entra-gebruikersobject-id. U kunt de object-id van Microsoft Entra-gebruikers ophalen via de Microsoft Graph REST API/gebruikerseindpunt van de id eigenschap in het antwoord. Zie Graph Explorer en bekijk de Graph SDK voor meer informatie over het werken met Microsoft Graph. U kunt de id ook vinden als claim oid in een id-token of Microsoft Entra-toegangstoken nadat uw gebruiker zich heeft aangemeld en een token heeft verkregen.
Basaal gebruik
// get the Teams user's ID if only the email is known, assuming a helper method for the Graph API
let userId = await getUserIdFromGraph("bob@contoso.com")
// create an identifier
let teamsUser = MicrosoftTeamsUserIdentifier(userId: userId)
// if you're not operating in the public cloud, you must also pass the right Cloud type.
let gcchTeamsUser = MicrosoftTeamsUserIdentifier(userId: userId, cloud: CommunicationCloudEnvironment.Gcch)
API-verwijzing
Telefoonnummer
Het PhoneNumberIdentifier vertegenwoordigt een telefoonnummer. De service gaat ervan uit dat telefoonnummers zijn opgemaakt in E.164-indeling.
Basaal gebruik
// create an identifier
let phoneNumber = PhoneNumberIdentifier(phoneNumber: "+112345556789")
API-verwijzing
Microsoft Teams-toepassing
De MicrosoftTeamsAppIdentifier interface vertegenwoordigt een bot van de Teams Voice-toepassingen zoals Oproepwachtrij en Auto Attendant met de object-id van de Microsoft Entra-bot. De Teams-toepassingen moeten worden geconfigureerd met een resourceaccount. U kunt de object-id van de Microsoft Entra-bot ophalen via de Microsoft Graph REST API/gebruikerseindpunt van de id eigenschap in het antwoord. Zie Graph Explorer en bekijk de Graph SDK voor meer informatie over het werken met Microsoft Graph.
Basaal gebruik
// Get the Microsoft Teams App's ID from Graph APIs, assuming a helper method for the Graph API
let botId = await getBotIdFromGraph()
// Create an identifier
let teamsAppIdentifier = MicrosoftTeamsAppIdentifier(appId: botId)
// If you're not operating in the public cloud, you must also pass the right Cloud type.
let gcchTeamsAppIdentifier = MicrosoftTeamsAppIdentifier(appId: botId, cloudEnvironment: CommunicationCloudEnvironment.Gcch)
API-verwijzing
Teams-extensiegebruiker
De TeamsExtensionUserIdentifier interface vertegenwoordigt een Teams-gebruiker die is ingeschakeld voor de uitbreidbaarheid van Teams-telefoons. A TeamsExtensionUserIdentifier vereist de Microsoft Entra-gebruikersobject-id van de Teams-gebruiker, de Tenant-id van Microsoft Entra waar de gebruiker zich bevindt en de Resource-id van Azure Communication Services. U kunt de Microsoft Entra-gebruikersobject-id ophalen via de Microsoft Graph REST API /users endpoint van de id eigenschap in de response, en de Microsoft Entra-tenant-id via de Microsoft Graph REST API /organization endpoint van de id eigenschap in de response. Zie Graph Explorer en bekijk de Graph SDK voor meer informatie over het werken met Microsoft Graph.
U kunt de object-id ook vinden als de oid claim en de tenant-id als de tid claim in een Microsoft Entra-token of Microsoft Entra-toegangstoken nadat uw gebruiker zich heeft aangemeld en een token heeft verkregen.
Basaal gebruik
// get the Teams user's ID if only the email is known, assuming a helper method for the Graph API
let userId = await getUserIdFromGraph("bob@contoso.com")
// get the tenantId from Graph API
let tenantId = await getTenantIdFromGraph()
// Communication Services Resource ID
let resourceId = "<resource-id-guid>"
// create an identifier
let teamsExtensionUser = TeamsExtensionUserIdentifier(userId: userId, tenantId: tenantId, resourceId: resourceId)
// if you're not operating in the public cloud, you must also pass the right Cloud type.
let gcchTeamsExtensionUser = TeamsExtensionUserIdentifier(userId: userId, tenantId: tenantId, resourceId: resourceId, cloudEnvironment: CommunicationCloudEnvironment.Gcch)
API-verwijzing
Onbekend
Het UnknownIdentifier bestaat voor toekomstbestendig maken en u kunt deze tegenkomen wanneer u een oude versie van de SDK gebruikt en er onlangs een nieuw id-type wordt geïntroduceerd. Een onbekende identifier van de service wordt gedeserialiseerd als UnknownIdentifier in de SDK.
Basaal gebruik
// create an identifier
let unknown = UnknownIdentifier("a raw id that originated in the service")
API-verwijzing
Hoe je omgaat met het basisprotocol CommunicationIdentifier
Terwijl u id's maakt voor een concreet type dat u in de SDK doorgeeft, retourneert de SDK het CommunicationIdentifier protocol. Het is eenvoudig om terug te casten naar een concreet type en we raden een switch-case-instructie met pattern matching aan.
switch (communicationIdentifier)
{
case let communicationUser as CommunicationUserIdentifier:
print(#"Communication user: \(communicationUser.id)"#)
case let teamsUser as MicrosoftTeamsUserIdentifier:
print(#"Teams user: \(teamsUser.UserId)"#)
case let teamsApp as MicrosoftTeamsAppIdentifier:
print(#"Teams app: \(teamsApp.appId)"#)
case let phoneNumber as PhoneNumberIdentifier:
print(#"Phone number: \(phoneNumber.PhoneNumber)"#)
case let unknown as UnknownIdentifier:
print(#"Unknown: \(unknown.Id)"#)
@unknown default:
// be careful here whether you want to throw because a new SDK version
// can introduce new identifier types
break;
}
Onbewerkte id-weergave
Soms moet u een id serialiseren naar een platte tekenreeks. Als u bijvoorbeeld de id wilt opslaan in een databasetabel of als u deze wilt gebruiken als URL-parameter.
Voor dat doel hebben id's een andere weergave met de naam RawId. Een id kan altijd worden omgezet in de bijbehorende onbewerkte id en een geldige onbewerkte id kan altijd worden geconverteerd naar een id.
Omdat Azure.Communication.Common 1.1.0 de SDK helpt bij de conversie:
Snel
// get an identifier's raw Id
let rawId = communicationIdentifier.rawId;
// create an identifier from a given raw Id
let identifier = createCommunicationIdentifier(fromRawId: rawId);
Een ongeldige ruwe ID wordt geconverteerd naar een UnknownIdentifier in de SDK en elke validatie vindt alleen plaats aan de serverzijde.
Communicatiegebruiker
De CommunicationUserIdentifier vertegenwoordigt een gebruikersidentiteit die is gemaakt met behulp van de Identity SDK of REST API. Dit is de enige id die wordt gebruikt als uw toepassing geen gebruik maakt van microsoft Teams-interoperabiliteits- of telefoniefuncties.
Basaal gebruik
// at some point you will have created a new user identity in your trusted service
CommunicationUserIdentifier newUser = identityClient.CreateUser();
// and then send newUser.getId() down to your client application
// where you can again create an identifier for the user
CommunicationUserIdentifier sameUser = new CommunicationUserIdentifier(newUserId);
API-verwijzing
Microsoft Teams-gebruiker
De MicrosoftTeamsUserIdentifier vertegenwoordigt een Teams-gebruiker met de microsoft Entra-gebruikersobject-id. U kunt de object-id van Microsoft Entra-gebruikers ophalen via de Microsoft Graph REST API/gebruikerseindpunt van de id eigenschap in het antwoord. Zie Graph Explorer en bekijk de Graph SDK voor meer informatie over het werken met Microsoft Graph. U kunt de id ook vinden als claim oid in een id-token of Microsoft Entra-toegangstoken nadat uw gebruiker zich heeft aangemeld en een token heeft verkregen.
Basaal gebruik
// get the Teams user's ID from Graph APIs if only the email is known
User user = graphClient.users("bob@contoso.com")
.buildRequest()
.get();
// create an identifier
MicrosoftTeamsUserIdentifier teamsUser = new MicrosoftTeamsUserIdentifier(user.id);
// if you're not operating in the public cloud, you must also set the right Cloud type.
MicrosoftTeamsUserIdentifier gcchTeamsUser = new MicrosoftTeamsUserIdentifier(userId).setCloudEnvironment(CommunicationCloudEnvironment.GCCH);
API-verwijzing
Telefoonnummer
Het PhoneNumberIdentifier vertegenwoordigt een telefoonnummer. De service gaat ervan uit dat telefoonnummers zijn opgemaakt in E.164-indeling.
Basaal gebruik
// create an identifier
PhoneNumberIdentifier phoneNumber = new PhoneNumberIdentifier("+112345556789");
API-verwijzing
Microsoft Teams-toepassing
De MicrosoftTeamsAppIdentifier interface vertegenwoordigt een bot van de Teams Voice-toepassingen zoals Oproepwachtrij en Auto Attendant met de object-id van de Microsoft Entra-bot. Configureer de Teams-toepassingen met een resourceaccount. U kunt de object-id van de Microsoft Entra-bot ophalen via de Microsoft Graph REST API/gebruikerseindpunt van de id eigenschap in het antwoord. Zie Graph Explorer en bekijk de Graph SDK voor meer informatie over het werken met Microsoft Graph.
Basaal gebruik
// Get the Microsoft Teams App's ID from Graph APIs
UserCollectionPage users = graphClient.users()
.buildRequest()
.filter(filterConditions)
.select("displayName,id")
.get();
//Here we assume that you have a function getBotFromUsers that gets the bot from the returned response
User bot = getBotFromUsers(users);
// Create an identifier
MicrosoftTeamsAppIdentifier teamsAppIdentifier = new MicrosoftTeamsAppIdentifier(bot.id);
// If you're not operating in the public cloud, you must also pass the right Cloud type.
MicrosoftTeamsAppIdentifier gcchTeamsAppIdentifier = new MicrosoftTeamsAppIdentifier(bot.id, CommunicationCloudEnvironment.GCCH);
API-verwijzing
Teams-extensiegebruiker
De TeamsExtensionUserIdentifier interface vertegenwoordigt een Teams-gebruiker die is ingeschakeld voor de uitbreidbaarheid van Teams-telefoons. A TeamsExtensionUserIdentifier vereist de Microsoft Entra-gebruikersobject-id van de Teams-gebruiker, de Tenant-id van Microsoft Entra waar de gebruiker zich bevindt en de Resource-id van Azure Communication Services. U kunt de Microsoft Entra-gebruikersobject-id ophalen via de Microsoft Graph REST API /users endpoint van de id eigenschap in de response, en de Microsoft Entra-tenant-id via de Microsoft Graph REST API /organization endpoint van de id eigenschap in de response. Zie Graph Explorer en bekijk de Graph SDK voor meer informatie over het werken met Microsoft Graph.
U kunt de object-id ook vinden als de oid claim en de tenant-id als de tid claim in een Microsoft Entra-token of Microsoft Entra-toegangstoken nadat uw gebruiker zich heeft aangemeld en een token heeft verkregen.
Basaal gebruik
// get the Teams user's ID from Graph APIs if only the email is known
User user = graphClient.users("bob@contoso.com")
.buildRequest()
.get();
// get the tenantId from Graph API
OrganizationCollectionPage organizations = graphClient.organization()
.buildRequest()
.get();
String tenantId = organizations.getCurrentPage().get(0).id;
// Communication Services Resource ID
var resourceId = "<resource-id-guid>";
// create an identifier
var teamsExtensionUser = new TeamsExtensionUserIdentifier(user.id, tenantId, resourceId);
// if you're not operating in the public cloud, you must also set the right Cloud type.
var gcchTeamsExtensionUser = new TeamsExtensionUserIdentifier(user.id, tenantId, resourceId).setCloudEnvironment(CommunicationCloudEnvironment.GCCH);
API-verwijzing
Onbekend
Het UnknownIdentifier bestaat voor toekomstbestendig maken en u kunt deze tegenkomen wanneer u een oude versie van de SDK gebruikt en er onlangs een nieuw id-type wordt geïntroduceerd. Een onbekende identifier van de service wordt gedeserialiseerd als UnknownIdentifier in de SDK.
Basaal gebruik
// create an identifier
UnknownIdentifier unknown = new UnknownIdentifier("a raw id that originated in the service");
API-verwijzing
Hoe je de basisklasse CommunicationIdentifier afhandelt
Terwijl u identificatoren maakt voor een concreet type dat u aan de SDK doorgeeft, retourneert de SDK de abstractie. U kunt terug casten naar een betontype:
if (communicationIdentifier instanceof CommunicationUserIdentifier) {
Log.i(tag, "Communication user: " + ((CommunicationUserIdentifier)communicationIdentifier).getId());
}
else if (communicationIdentifier instanceof MicrosoftTeamsUserIdentifier) {
Log.i(tag, "Teams user: " + ((MicrosoftTeamsUserIdentifier)communicationIdentifier).getUserId());
}
else if (communicationIdentifier instanceof MicrosoftTeamsAppIdentifier) {
Log.i(tag, "Teams app: " + (( MicrosoftTeamsAppIdentifier)communicationIdentifier).getAppId());
}
else if (communicationIdentifier instanceof PhoneNumberIdentifier) {
Log.i(tag, "Phone number: " + ((PhoneNumberIdentifier)communicationIdentifier).getPhoneNumber());
}
else if (communicationIdentifier instanceof UnknownIdentifier) {
Log.i(tag, "Unknown user: " + ((UnknownIdentifier)communicationIdentifier).getId());
}
else {
// be careful here whether you want to throw because a new SDK version
// can introduce new identifier types
}
Onbewerkte id-weergave
Soms moet u een id serialiseren naar een platte tekenreeks. Als u bijvoorbeeld de id wilt opslaan in een databasetabel of als u deze wilt gebruiken als URL-parameter.
Voor dat doel hebben id's een andere weergave met de naam RawId. Een id kan altijd worden omgezet in de bijbehorende onbewerkte id en een geldige onbewerkte id kan altijd worden geconverteerd naar een id.
Omdat azure-communication-common 1.1.0 de SDK helpt bij de conversie:
// get an identifier's raw Id
String rawId = communicationIdentifier.getRawId();
// create an identifier from a given raw Id
CommunicationIdentifier identifier = CommunicationIdentifier.fromRawId(rawId);
Een ongeldige onbewerkte id wordt geconverteerd naar UnknownIdentifier in de SDK en elke validatie vindt alleen plaats aan de servicezijde.
In REST API's is de id een polymorf type: u maakt een JSON-object en een eigenschap die is toegewezen aan een subtype van een concrete id. Om redenen van gemak en compatibiliteit met eerdere versies zijn de kind en rawId eigenschappen optioneel in aanvragen, maar worden ze ingevuld in servicereacties.
Communicatiegebruiker
De CommunicationUserIdentifierModel vertegenwoordigt een gebruikersidentiteit die is gemaakt met behulp van de Identity SDK of REST API. Dit is de enige id die wordt gebruikt als uw toepassing geen gebruik maakt van microsoft Teams-interoperabiliteits- of telefoniefuncties.
Basaal gebruik
// at some point you will have created a new user identity in your trusted service
// you can specify an identifier with the id of the new user in a request
{
"communicationUser": {
"id": "8:acs:8540c0de-899f-5cce-acb5-3ec493af3800_c94ff260-162d-46d6-94fd-e79f4d213715"
}
}
// the corresponding serialization in a response
{
"kind": "communicationUser",
"rawId": "8:acs:8540c0de-899f-5cce-acb5-3ec493af3800_c94ff260-162d-46d6-94fd-e79f4d213715",
"communicationUser": {
"id": "8:acs:8540c0de-899f-5cce-acb5-3ec493af3800_c94ff260-162d-46d6-94fd-e79f4d213715"
}
}
U vindt een voorbeeld van een aanvraag met een id in de CHAT REST API voor het toevoegen van een deelnemer en een voorbeeld voor een antwoord met een id onder chatbericht ophalen.
API-verwijzing
CommunicationUserIdentifierModel
Microsoft Teams-gebruiker
De MicrosoftTeamsUserIdentifierModel vertegenwoordigt een Teams-gebruiker met de microsoft Entra-gebruikersobject-id. U kunt de object-id van Microsoft Entra-gebruikers ophalen via de Microsoft Graph REST API/gebruikerseindpunt van de id eigenschap in het antwoord. Zie Graph Explorer en bekijk de Graph SDK voor meer informatie over het werken met Microsoft Graph. U kunt de id ook vinden als claim oid in een Microsoft Entra-token of Microsoft Entra-toegangstoken nadat uw gebruiker zich heeft aangemeld en een token heeft verkregen.
Basaal gebruik
// request
{
"microsoftTeamsUser": {
"userId": "00aa00aa-bb11-cc22-dd33-44ee44ee44ee"
}
}
// response
{
"kind": "microsoftTeamsUser",
"rawId": "8:orgid:00aa00aa-bb11-cc22-dd33-44ee44ee44ee",
"microsoftTeamsUser": {
"userId": "00aa00aa-bb11-cc22-dd33-44ee44ee44ee"
}
}
// if you're not operating in the public cloud, you must also pass the right Cloud type in a request
{
"microsoftTeamsUser": {
"userId": "00aa00aa-bb11-cc22-dd33-44ee44ee44ee",
"cloud": "gcch"
}
}
// response
{
"kind": "microsoftTeamsUser",
"rawId": "8:gcch:00aa00aa-bb11-cc22-dd33-44ee44ee44ee",
"microsoftTeamsUser": {
"userId": "00aa00aa-bb11-cc22-dd33-44ee44ee44ee",
"isAnonymous": false,
"cloud": "gcch"
}
}
API-verwijzing
MicrosoftTeamsUserIdentifierModel
Telefoonnummer
Het PhoneNumberIdentifierModel vertegenwoordigt een telefoonnummer. De service gaat ervan uit dat telefoonnummers zijn opgemaakt in E.164-indeling.
Basaal gebruik
// request
{
"phoneNumber": {
"value": "+112345556789"
}
}
// response
{
"kind": "phoneNumber",
"rawId": "4:+112345556789",
"phoneNumber": {
"value": "+112345556789"
}
}
API-verwijzing
Microsoft Teams-toepassing
Het MicrosoftTeamsAppIdentifierModel vertegenwoordigt een bot van de Teams Voice-toepassingen zoals Oproepwachtrij en Auto Attendant met de object-id van de Microsoft Entra-bot. De Teams-toepassingen moeten worden geconfigureerd met een resourceaccount. U kunt de object-id van de Microsoft Entra-bot ophalen via de Microsoft Graph REST API/gebruikerseindpunt van de id eigenschap in het antwoord. Zie Graph Explorer en bekijk de Graph SDK voor meer informatie over het werken met Microsoft Graph.
Basaal gebruik
// request
{
"microsoftTeamsApp": {
"appId": "00001111-aaaa-2222-bbbb-3333cccc4444"
}
}
// response
{
"kind": "microsoftTeamsApp",
"rawId": "28:orgid:00001111-aaaa-2222-bbbb-3333cccc4444",
"microsoftTeamsApp": {
"appId": "00001111-aaaa-2222-bbbb-3333cccc4444"
}
}
// if you're not operating in the public cloud, you must also pass the right Cloud type in a request
{
"microsoftTeamsApp": {
"appId": "00001111-aaaa-2222-bbbb-3333cccc4444",
"cloud": "gcch"
}
}
// response
{
"kind": "microsoftTeamsApp",
"rawId": "28:gcch:00001111-aaaa-2222-bbbb-3333cccc4444",
"microsoftTeamsApp": {
"appId": "00001111-aaaa-2222-bbbb-3333cccc4444",
"cloud": "gcch"
}
}
API-verwijzing
MicrosoftTeamsAppIdentifierModel
Teams-extensiegebruiker
De TeamsExtensionUserIdentifier interface vertegenwoordigt een Teams-gebruiker die is ingeschakeld voor de uitbreidbaarheid van Teams-telefoons. A TeamsExtensionUserIdentifier vereist de Microsoft Entra-gebruikersobject-id van de Teams-gebruiker, de Tenant-id van Microsoft Entra waar de gebruiker zich bevindt en de Resource-id van Azure Communication Services. U kunt de Microsoft Entra-gebruikersobject-id ophalen via de Microsoft Graph REST API /users endpoint van de id eigenschap in de response, en de Microsoft Entra-tenant-id via de Microsoft Graph REST API /organization endpoint van de id eigenschap in de response. Zie Graph Explorer en bekijk de Graph SDK voor meer informatie over het werken met Microsoft Graph.
U kunt de object-id ook vinden als de oid claim en de tenant-id als de tid claim in een Microsoft Entra-token of Microsoft Entra-toegangstoken nadat uw gebruiker zich heeft aangemeld en een token heeft verkregen.
Basaal gebruik
// request
{
"teamsExtensionUser": {
"userId": "00aa00aa-bb11-cc22-dd33-44ee44ee44ee",
"tenantId": "d4f5a8c3-2c49-4b9e-a5c6-3c85e80a7f4d",
"resourceId": "f7e1e3c6-3a1d-4415-8b7d-9e1d4bda2d45"
}
}
// response
{
"kind": "teamsExtensionUser",
"rawId": "8:acs:f7e1e3c6-3a1d-4415-8b7d-9e1d4bda2d45_d4f5a8c3-2c49-4b9e-a5c6-3c85e80a7f4d_00aa00aa-bb11-cc22-dd33-44ee44ee44ee",
"teamsExtensionUser": {
"userId": "00aa00aa-bb11-cc22-dd33-44ee44ee44ee",
"tenantId": "d4f5a8c3-2c49-4b9e-a5c6-3c85e80a7f4d",
"resourceId": "f7e1e3c6-3a1d-4415-8b7d-9e1d4bda2d45"
}
}
// if you're not operating in the public cloud, you must also pass the right Cloud type in a request
{
"microsoftTeamsUser": {
"userId": "00aa00aa-bb11-cc22-dd33-44ee44ee44ee",
"tenantId": "d4f5a8c3-2c49-4b9e-a5c6-3c85e80a7f4d",
"resourceId": "f7e1e3c6-3a1d-4415-8b7d-9e1d4bda2d45",
"cloud": "gcch"
}
}
// response
{
"kind": "teamsExtensionUser",
"rawId": "8:gcch-acs:f7e1e3c6-3a1d-4415-8b7d-9e1d4bda2d45_d4f5a8c3-2c49-4b9e-a5c6-3c85e80a7f4d_00aa00aa-bb11-cc22-dd33-44ee44ee44ee",
"teamsExtensionUser": {
"userId": "00aa00aa-bb11-cc22-dd33-44ee44ee44ee",
"tenantId": "d4f5a8c3-2c49-4b9e-a5c6-3c85e80a7f4d",
"resourceId": "f7e1e3c6-3a1d-4415-8b7d-9e1d4bda2d45",
"cloud": "gcch"
}
}
API-verwijzing
TeamsExtensionUserIdentifierModel
Onbekend
Als er een nieuwe identificator wordt geïntroduceerd in een service, wordt deze teruggebracht naar CommunicationIdentifierModel als u een oude API-versie gebruikt.
Basaal gebruik
// request
{
"rawId": "a raw id that originated in the service"
}
// response
{
"kind": "unknown",
"rawId": "a raw id that originated in the service"
}
API-verwijzing
Hoe om te gaan met de CommunicationIdentifierModel in reacties
Recente API-versies vullen een kind eigenschap in die u kunt gebruiken om onderscheid te maken tussen.
switch (communicationIdentifier.kind)
{
case "communicationUser":
console.log(`Communication user: ${communicationIdentifier.communicationUser.id}`);
break;
case "microsoftTeamsUser":
console.log(`Teams user: ${communicationIdentifier.microsoftTeamsUser.userId}`);
break;
case "microsoftTeamsApp":
console.log(`Teams user: ${communicationIdentifier.microsoftTeamsApp.appId}`);
break;
case "phoneNumber":
console.log(`Phone number: ${communicationIdentifier.phoneNumber.value}`);
break;
case "unknown":
console.log(`Unknown: ${communicationIdentifier.rawId}`);
break;
default:
// this case should not be hit because adding a new identifier type requires a new API version
// if it does get hit, please file an issue on https://github.com/Azure/azure-rest-api-specs/issues
break;
}
In oudere API-versies ontbreekt de kind eigenschap en moet u controleren op de juiste subeigenschap:
if (communicationIdentifier.communicationUser) {
console.log(`Communication user: ${communicationIdentifier.communicationUser.id}`);
} else if (communicationIdentifier.microsoftTeamsUser) {
console.log(`Teams user: ${communicationIdentifier.microsoftTeamsUser.userId}`);
} else if (communicationIdentifier.microsoftTeamsApp) {
console.log(`Teams app: ${communicationIdentifier.microsoftTeamsApp.appId}`);
} else if (communicationIdentifier.phoneNumber) {
console.log(`Phone number: ${communicationIdentifier.phoneNumber.value}`);
} else {
console.log(`Unknown: ${communicationIdentifier.rawId}`);
}
Onbewerkte id-weergave
Soms moet u een id serialiseren naar een platte tekenreeks. Als u bijvoorbeeld de id wilt opslaan in een databasetabel of als u deze wilt gebruiken als URL-parameter.
Voor dat doel hebben id's een andere weergave met de naam RawId. Een id kan altijd worden omgezet in de bijbehorende onbewerkte id en een geldige onbewerkte id kan altijd worden geconverteerd naar een id.
Als u de Azure SDK gebruikt, helpt dit u bij de conversie. Als u de REST API rechtstreeks gebruikt, moet u de onbewerkte id als volgt handmatig samenstellen.
Communicatiegebruiker
Identificatie:
{
"communicationUser": {
"id": "[communicationUserId]"
}
}
Ruwe ID:
[communicationUserId]
De onbewerkte id is hetzelfde als communicationUser.id.
Microsoft Teams-gebruiker
Identificatie:
{
"microsoftTeamsUser": {
"userId": "[entraUserId]"
}
}
Ruwe ID:
8:orgid:[entraUserId]
De onbewerkte id is de Microsoft Entra-gebruikersobject-id met 8:orgid: voorvoegsel.
Identificatie:
{
"microsoftTeamsUser": {
"userId": "[entraUserId]",
"cloud": "gcch"
}
}
Ruwe ID:
8:gcch:[entraUserId]
De ruwe ID is de Microsoft Entra-gebruikersobject-ID die voorafgegaan wordt door 8:gcch: of 8:dod:, afhankelijk van de cloudomgeving.
Identificatie:
{
"microsoftTeamsUser": {
"userId": "[visitorUserId]",
"isAnonymous": true
}
}
Ruwe ID:
8:teamsvisitor:[visitorUserId]
De onbewerkte ID is de bezoekers-ID van Teams met het voorvoegsel 8:teamsvisitor:. De Bezoekers-id van Teams is een tijdelijke id die Teams genereert om toegang tot vergaderingen mogelijk te maken.
Telefoonnummer
Identificatie:
{
"phoneNumber": {
"value": "+1123455567"
}
}
Ruwe ID:
4:+1123455567
De onbewerkte id is het E.164 opgemaakte telefoonnummer met voorvoegsel 4:.
Microsoft Teams-app
Identificatie:
{
"microsoftTeamsApp": {
"appId": "[entraUserId]"
}
}
Ruwe ID:
28:orgid:[entraUserId]
De onbewerkte id is de Microsoft Entra-gebruikersobject-id van de toepassing met 28:orgid:het voorvoegsel .
Identificatie:
{
"microsoftTeamsUser": {
"userId": "[entraUserId]",
"cloud": "gcch"
}
}
Ruwe ID:
28:gcch:[entraUserId]
De onbewerkte id is de Microsoft Entra-gebruikersobject-id van de toepassing, voorafgegaan door 28:gcch: of 28:dod: afhankelijk van de cloudomgeving.
Onbekend
Identificatie:
{
"rawId": "[unknown identifier id]"
}
Ruwe ID:
[unknown identifier id]
Als een onbewerkte id ongeldig is, mislukt de service de aanvraag.
Volgende stappen
- Zie Identiteitsmodel voor een inleiding tot communicatie-identiteiten.
- Zie de quick-create identity quickstart voor instructies om snel identiteiten te maken voor testen.
- Zie De interoperabiliteit van Teams voor meer informatie over het gebruik van Communication Services in combinatie met Microsoft Teams.
- Zie Gebruikstoepassingen voor string-ID's in communicatiesoftwareontwikkelingskits voor meer informatie over het gebruik van een ruwe ID.