Share via


식별자 유형 이해

Communication Services SDK 및 REST API는 식별자 유형을 사용하여 누구와 통신하고 있는지 식별합니다. 예를 들어 식별자는 전화를 거는 사람 또는 채팅 메시지를 보낸 사람을 지정합니다.

컨텍스트에 따라 식별자는 채팅 SDK의 내부 ChatParticipant 또는 통화 SDK의 내부 RemoteParticipant와 같은 추가 속성으로 래핑됩니다.

이 문서에서는 다양한 유형의 식별자와 해당 식별자가 프로그래밍 언어에서 어떻게 보이는지에 대해 알아봅니다. 또한 사용 방법에 대한 팁을 얻을 수 있습니다.

CommunicationIDentifier 형식

직접 만드는 사용자 ID가 있으며 외부 ID가 있습니다. Microsoft Teams 사용자 및 전화 번호는 interop 시나리오에서 재생되는 외부 ID입니다. 이러한 각 ID 형식에는 해당 ID 형식을 나타내는 식별자가 있습니다. 식별자는 형식이 안전하고 편집기 코드 완성과 잘 작동하는 구조화된 형식입니다.

통신 사용자

CommunicationUserIdentifier 인터페이스는 ID SDK 또는 REST API를 사용하여 만든 사용자 ID를 나타냅니다. 애플리케이션에서 Microsoft Teams 상호 운용성 또는 전화 통신 기능을 사용하지 않는 경우 사용되는 유일한 식별자입니다.

기본 사용법

// 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 참조

CommunicationUserIdentifier

Microsoft Teams 사용자

MicrosoftTeamsUserIdentifier 인터페이스는 Microsoft Entra 사용자 개체 ID를 가진 Teams 사용자를 나타냅니다. 응답의 id 속성에서 Microsoft Graph REST API /users 엔드포인트를 통해 Microsoft Entra 사용자 개체 ID를 검색할 수 있습니다. Microsoft Graph를 사용하는 방법에 대한 자세한 내용은 Graph 탐색기를 사용해 보고 Graph SDK를 확인하세요. 또는 사용자가 로그인하여 토큰을 획득한 후 ID를 Microsoft Entra 토큰 또는 Microsoft Entra 액세스 토큰에서 oid 클레임으로 찾을 수 있습니다.

기본 사용법

// 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 참조

MicrosoftTeamsUserIDentifier

전화번호

PhoneNumberIdentifier 인터페이스는 전화 번호를 나타냅니다. 이 서비스는 전화 번호의 형식이 E.164 형식이라고 가정합니다.

기본 사용법

// create an identifier
const phoneNumber = { phoneNumber: "+112345556789" };

API 참조

PhoneNumberIDentifier

Microsoft Teams 애플리케이션

MicrosoftTeamsAppIdentifier 인터페이스는 Microsoft Entra 봇 개체 ID를 사용하여 통화 큐 및 자동 전화 교환과 같은 Teams Voice 애플리케이션의 봇을 나타냅니다. Teams 애플리케이션은 리소스 계정으로 구성되어야 합니다. 응답의 id 속성에서 Microsoft Graph REST API /users 엔드포인트를 통해 Microsoft Entra 봇 개체 ID를 검색할 수 있습니다. Microsoft Graph를 사용하는 방법에 대한 자세한 내용은 Graph 탐색기를 사용해 보고 Graph SDK를 확인하세요.

기본 사용법

// 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 참조

MicrosoftTeamsAppIdentifier

Unknown

UnknownIdentifier 인터페이스는 미래 언어 교정을 위해 존재하며 이전 버전의 SDK에 있고 최근에 새 식별자 형식이 도입되었을 때 인터페이스가 발생할 수 있습니다. 서비스의 알 수 없는 식별자는 SDK의 UnknownIdentifier로 역직렬화됩니다.

기본 사용법

// create an identifier
const unknownId = { id: "a raw id that originated in the service" };

API 참조

UnknownIdentifier

CommunicationIdentifier 기본 인터페이스를 처리하는 방법

SDK에 전달하는 구체적인 형식에 대한 식별자를 생성하는 동안 SDK는 구분된 공용 구조체CommunicationIdentifierKind를 반환합니다. 구체적인 형식으로 쉽게 좁힐 수 있으며 패턴이 일치하는 switch-case 문을 제안합니다.

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 "phoneNumber":
         // narrowed to PhoneNumberKind
        console.log(`Phone number: ${communicationIdentifier.phoneNumber}`);
        break;
    case "unknown":
         // narrowed to UnknownIdentifierKind
        console.log(`Unknown: ${communicationIdentifier.id}`);
        break;
    case "microsoftBot":
        // narrowed to MicrosoftBotIdentifier
        console.log(`Microsoft bot: ${communicationIdentifier.botId}`);
        break;
    default:
        // be careful here whether you want to throw because a new SDK version
        // can introduce new identifier types
        break;
}

식별자 인터페이스는 세부 정보를 줄이기 위해 kind를 지정할 필요가 없도록 설계되었으며 kind 속성과의 구분 공용 구조체는 SDK에서 반환될 때만 사용됩니다. 그러나 식별자를 해당 구분 공용 구조체 형식으로 변환해야 하는 경우 다음 도우미를 사용할 수 있습니다.

const identifierKind = getIdentifierKind(identifier); // now you can switch-case on the kind

원시 ID 표현

경우에 따라 식별자를 플랫 문자열로 직렬화해야 합니다. 예를 들어 데이터베이스 테이블에 식별자를 저장하거나 URL 매개 변수로 사용하려는 경우입니다.

이를 위해 식별자에는 RawId라는 다른 표현이 있습니다. 식별자는 항상 해당 원시 ID로 변환될 수 있으며 유효한 원시 ID는 항상 식별자로 변환될 수 있습니다.

azure-communication-common@2.1.0 SDK는 다음 변환에 도움이 됩니다.

// get an identifier's raw Id
const rawId = getIdentifierRawId(communicationIdentifier);

// create an identifier from a given raw Id
const identifier = createIdentifierFromRawId(rawId);

잘못된 원시 ID는 SDK에서 UnknownIdentifier로 변환되며 모든 유효성 검사는 서비스 쪽에서만 발생합니다.

통신 사용자

CommunicationUserIdentifierID SDK 또는 REST API를 사용하여 만든 사용자 ID를 나타냅니다. 애플리케이션에서 Microsoft Teams 상호 운용성 또는 전화 통신 기능을 사용하지 않는 경우 사용되는 유일한 식별자입니다.

기본 사용법

// 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 참조

CommunicationUserIdentifier

Microsoft Teams 사용자

MicrosoftTeamsUserIdentifier은 Microsoft Entra 사용자 개체 ID를 가진 Teams 사용자를 나타냅니다. 응답의 id 속성에서 Microsoft Graph REST API /users 엔드포인트를 통해 Microsoft Entra 사용자 개체 ID를 검색할 수 있습니다. Microsoft Graph를 사용하는 방법에 대한 자세한 내용은 Graph 탐색기를 사용해 보고 Graph SDK를 확인하세요. 또는 사용자가 로그인하여 토큰을 획득한 후 ID를 Microsoft Entra 토큰 또는 Microsoft Entra 액세스 토큰에서 oid 클레임으로 찾을 수 있습니다.

기본 사용법

// 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 참조

MicrosoftTeamsUserIDentifier

전화번호

PhoneNumberIdentifier는 전화번호를 나타냅니다. 이 서비스는 전화 번호의 형식이 E.164 형식이라고 가정합니다.

기본 사용법

// create an identifier
var phoneNumber = new PhoneNumberIdentifier("+112345556789");

API 참조

PhoneNumberIDentifier

Microsoft Teams 애플리케이션

MicrosoftTeamsAppIdentifier 인터페이스는 Microsoft Entra 봇 개체 ID를 사용하여 통화 큐 및 자동 전화 교환과 같은 Teams Voice 애플리케이션의 봇을 나타냅니다. Teams 애플리케이션은 리소스 계정으로 구성되어야 합니다. 응답의 id 속성에서 Microsoft Graph REST API /users 엔드포인트를 통해 Microsoft Entra 봇 개체 ID를 검색할 수 있습니다. Microsoft Graph를 사용하는 방법에 대한 자세한 내용은 Graph 탐색기를 사용해 보고 Graph SDK를 확인하세요.

기본 사용법

// 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 참조

MicrosoftTeamsAppIdentifier

Unknown

UnknownIdentifier는 미래 언어 교정을 위해 존재하며 이전 버전의 SDK에 있고 최근에 새 식별자 형식이 도입되었을 때 인터페이스가 발생할 수 있습니다. 서비스의 알 수 없는 식별자는 SDK의 UnknownIdentifier로 역직렬화됩니다.

기본 사용법

// create an identifier
var unknown = new UnknownIdentifier("a raw id that originated in the service");

API 참조

UnknownIdentifier

CommunicationIdentifier 기본 클래스를 처리하는 방법

SDK에 전달하는 구체적인 형식에 대한 식별자를 생성하는 동안 SDK는 CommunicationIdentifier 프로토콜을 반환합니다. 구체적인 형식으로 쉽게 다운 캐스팅할 수 있으며 패턴이 일치하는 switch-case 문을 제안합니다.

switch (communicationIdentifier)
{
    case CommunicationUserIdentifier communicationUser:
        Console.WriteLine($"Communication user: {communicationUser.Id}");
        break;
    case MicrosoftTeamsUserIdentifier teamsUser:
        Console.WriteLine($"Teams user: {teamsUser.UserId}");
        break;
    case PhoneNumberIdentifier phoneNumber:
        Console.WriteLine($"Phone number: {phoneNumber.PhoneNumber}");
        break;
    case MicrosoftBotIdentifier bot:
        Console.WriteLine($"Microsoft bot: {bot.BotId}");
        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;
}

원시 ID 표현

경우에 따라 식별자를 플랫 문자열로 직렬화해야 합니다. 예를 들어 데이터베이스 테이블에 식별자를 저장하거나 URL 매개 변수로 사용하려는 경우입니다.

이를 위해 식별자에는 RawId라는 다른 표현이 있습니다. 식별자는 항상 해당 원시 ID로 변환될 수 있으며 유효한 원시 ID는 항상 식별자로 변환될 수 있습니다.

Azure.Communication.Common 1.2.0 SDK는 다음 변환에 도움이 됩니다.

// get an identifier's raw Id
string rawId = communicationIdentifier.RawId;

// create an identifier from a given raw Id
CommunicationIdentifier identifier = CommunicationIdentifier.FromRawId(rawId);

잘못된 원시 ID는 SDK에서 UnknownIdentifier로 변환되며 모든 유효성 검사는 서비스 쪽에서만 발생합니다.

통신 사용자

CommunicationUserIdentifierID SDK 또는 REST API를 사용하여 만든 사용자 ID를 나타냅니다. 애플리케이션에서 Microsoft Teams 상호 운용성 또는 전화 통신 기능을 사용하지 않는 경우 사용되는 유일한 식별자입니다.

기본 사용법

# 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 참조

CommunicationUserIdentifier

Microsoft Teams 사용자

MicrosoftTeamsUserIdentifier은 Microsoft Entra 사용자 개체 ID를 가진 Teams 사용자를 나타냅니다. 응답의 id 속성에서 Microsoft Graph REST API /users 엔드포인트를 통해 Microsoft Entra 사용자 개체 ID를 검색할 수 있습니다. Microsoft Graph를 사용하는 방법에 대한 자세한 내용은 Graph 탐색기를 사용해 보고 Graph SDK를 확인하세요. 또는 사용자가 로그인하여 토큰을 획득한 후 ID를 Microsoft Entra 토큰 또는 Microsoft Entra 액세스 토큰에서 oid 클레임으로 찾을 수 있습니다.

기본 사용법

# 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 참조

MicrosoftTeamsUserIDentifier

전화번호

PhoneNumberIdentifier는 전화번호를 나타냅니다. 이 서비스는 전화 번호의 형식이 E.164 형식이라고 가정합니다.

기본 사용법

# create an identifier
phone_number = PhoneNumberIdentifier("+112345556789")

API 참조

PhoneNumberIDentifier

Microsoft Teams 애플리케이션

MicrosoftTeamsAppIdentifier 인터페이스는 Microsoft Entra 봇 개체 ID를 사용하여 통화 큐 및 자동 전화 교환과 같은 Teams Voice 애플리케이션의 봇을 나타냅니다. Teams 애플리케이션은 리소스 계정으로 구성되어야 합니다. 응답의 id 속성에서 Microsoft Graph REST API /users 엔드포인트를 통해 Microsoft Entra 봇 개체 ID를 검색할 수 있습니다. Microsoft Graph를 사용하는 방법에 대한 자세한 내용은 Graph 탐색기를 사용해 보고 Graph SDK를 확인하세요.

기본 사용법

# 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 참조

MicrosoftTeamsAppIdentifier

Unknown

UnknownIdentifier는 미래 언어 교정을 위해 존재하며 이전 버전의 SDK에 있고 최근에 새 식별자 형식이 도입되었을 때 인터페이스가 발생할 수 있습니다. 서비스의 알 수 없는 식별자는 SDK의 UnknownIdentifier로 역직렬화됩니다.

기본 사용법

# create an identifier
unknown = UnknownIdentifier("a raw id that originated in the service")

API 참조

UnknownIdentifier

CommunicationIdentifier 기본 클래스를 처리하는 방법

SDK에 전달하는 구체적인 형식에 대한 식별자를 생성하는 동안 SDK는 CommunicationIdentifier 프로토콜을 반환합니다. 구체적인 식별자 클래스는 properties라는 형식화된 사전과 함께 CommunicationIdentifier 프로토콜일 뿐입니다. 따라서 프로토콜의 kind 인스턴스 변수에서 패턴 일치를 사용하여 구체적인 형식으로 변환할 수 있습니다.

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.PHONE_NUMBER:
        print(f"Phone number: {communication_identifier.properties['value']}")
    case CommunicationIdentifierKind.MICROSOFT_BOT:
        print(f"Microsoft bot: {communication_identifier.properties['bot_id']}")
    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

원시 ID 표현

경우에 따라 식별자를 플랫 문자열로 직렬화해야 합니다. 예를 들어 데이터베이스 테이블에 식별자를 저장하거나 URL 매개 변수로 사용하려는 경우입니다.

이를 위해 식별자에는 RawId라는 다른 표현이 있습니다. 식별자는 항상 해당 원시 ID로 변환될 수 있으며 유효한 원시 ID는 항상 식별자로 변환될 수 있습니다.

SDK는 다음 변환에 도움이 됩니다.

# 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)

잘못된 원시 ID는 SDK에서 UnknownIdentifier로 변환되며 모든 유효성 검사는 서비스 쪽에서만 발생합니다.

통신 사용자

CommunicationUserIdentifierID SDK 또는 REST API를 사용하여 만든 사용자 ID를 나타냅니다. 애플리케이션에서 Microsoft Teams 상호 운용성 또는 전화 통신 기능을 사용하지 않는 경우 사용되는 유일한 식별자입니다.

기본 사용법

// 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 참조

CommunicationUserIdentifier

Microsoft Teams 사용자

MicrosoftTeamsUserIdentifier은 Microsoft Entra 사용자 개체 ID를 가진 Teams 사용자를 나타냅니다. 응답의 id 속성에서 Microsoft Graph REST API /users 엔드포인트를 통해 Microsoft Entra 사용자 개체 ID를 검색할 수 있습니다. Microsoft Graph를 사용하는 방법에 대한 자세한 내용은 Graph 탐색기를 사용해 보고 Graph SDK를 확인하세요. 또는 사용자가 로그인하여 토큰을 획득한 후 ID를 Microsoft Entra 토큰 또는 Microsoft Entra 액세스 토큰에서 oid 클레임으로 찾을 수 있습니다.

기본 사용법

// 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 참조

MicrosoftTeamsUserIDentifier

전화번호

PhoneNumberIdentifier는 전화번호를 나타냅니다. 이 서비스는 전화 번호의 형식이 E.164 형식이라고 가정합니다.

기본 사용법

// create an identifier
var phoneNumber = new PhoneNumberIdentifier("+112345556789");

API 참조

PhoneNumberIDentifier

Microsoft Teams 애플리케이션

MicrosoftTeamsAppIdentifier 인터페이스는 Microsoft Entra 봇 개체 ID를 사용하여 통화 큐 및 자동 전화 교환과 같은 Teams Voice 애플리케이션의 봇을 나타냅니다. Teams 애플리케이션은 리소스 계정으로 구성되어야 합니다. 응답의 id 속성에서 Microsoft Graph REST API /users 엔드포인트를 통해 Microsoft Entra 봇 개체 ID를 검색할 수 있습니다. Microsoft Graph를 사용하는 방법에 대한 자세한 내용은 Graph 탐색기를 사용해 보고 Graph SDK를 확인하세요.

기본 사용법

// 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 참조

MicrosoftTeamsAppIdentifier

Unknown

UnknownIdentifier는 미래 언어 교정을 위해 존재하며 이전 버전의 SDK에 있고 최근에 새 식별자 형식이 도입되었을 때 인터페이스가 발생할 수 있습니다. 서비스의 알 수 없는 식별자는 SDK의 UnknownIdentifier로 역직렬화됩니다.

기본 사용법

// create an identifier
var unknown = new UnknownIdentifier("a raw id that originated in the service");

API 참조

UnknownIdentifier

CommunicationIdentifier 기본 클래스를 처리하는 방법

SDK에 전달하는 구체적인 형식에 대한 식별자를 생성하는 동안 SDK는 추상 CommunicationIdentifier를 반환합니다. 구체적인 형식으로 다시 다운 캐스팅할 수 있습니다.

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 PhoneNumberIdentifier) {
    System.out.println("Phone number: " + ((PhoneNumberIdentifier)communicationIdentifier).getPhoneNumber());
}
else if (communicationIdentifier instanceof MicrosoftBotIdentifier) {
    Log.i(tag, "Microsoft bot: " + ((MicrosoftBotIdentifier)communicationIdentifier).getBotId());
}
else if (communicationIdentifier instanceof UnknownIdentifier) {
    System.out.println("Unkown user: " + ((UnknownIdentifier)communicationIdentifier).getId());
}
else {
    // be careful here whether you want to throw because a new SDK version
        // can introduce new identifier types
}

원시 ID 표현

경우에 따라 식별자를 플랫 문자열로 직렬화해야 합니다. 예를 들어 데이터베이스 테이블에 식별자를 저장하거나 URL 매개 변수로 사용하려는 경우입니다.

이를 위해 식별자에는 RawId라는 다른 표현이 있습니다. 식별자는 항상 해당 원시 ID로 변환될 수 있으며 유효한 원시 ID는 항상 식별자로 변환될 수 있습니다.

azure-communication-common 1.2.0 SDK는 다음 변환에 도움이 됩니다.

// get an identifier's raw Id
String rawId = communicationIdentifier.getRawId();

// create an identifier from a given raw Id
CommunicationIdentifier identifier = CommunicationIdentifier.fromRawId(rawId);

잘못된 원시 ID는 SDK에서 UnknownIdentifier로 변환되며 모든 유효성 검사는 서비스 쪽에서만 발생합니다.

통신 사용자

CommunicationUserIdentifierID SDK 또는 REST API를 사용하여 만든 사용자 ID를 나타냅니다. 애플리케이션에서 Microsoft Teams 상호 운용성 또는 전화 통신 기능을 사용하지 않는 경우 사용되는 유일한 식별자입니다.

기본 사용법

// 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 참조

CommunicationUserIdentifier

Microsoft Teams 사용자

MicrosoftTeamsUserIdentifier은 Microsoft Entra 사용자 개체 ID를 가진 Teams 사용자를 나타냅니다. 응답의 id 속성에서 Microsoft Graph REST API /users 엔드포인트를 통해 Microsoft Entra 사용자 개체 ID를 검색할 수 있습니다. Microsoft Graph를 사용하는 방법에 대한 자세한 내용은 Graph 탐색기를 사용해 보고 Graph SDK를 확인하세요. 또는 사용자가 로그인하여 토큰을 획득한 후 ID를 ID 토큰 또는 Microsoft Entra 액세스 토큰에서 oid 클레임으로 찾을 수 있습니다.

기본 사용법

// 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 참조

MicrosoftTeamsUserIDentifier

전화번호

PhoneNumberIdentifier는 전화번호를 나타냅니다. 이 서비스는 전화 번호의 형식이 E.164 형식이라고 가정합니다.

기본 사용법

// create an identifier
let phoneNumber = PhoneNumberIdentifier(phoneNumber: "+112345556789")

API 참조

PhoneNumberIDentifier

Microsoft Teams 애플리케이션

MicrosoftTeamsAppIdentifier 인터페이스는 Microsoft Entra 봇 개체 ID를 사용하여 통화 큐 및 자동 전화 교환과 같은 Teams Voice 애플리케이션의 봇을 나타냅니다. Teams 애플리케이션은 리소스 계정으로 구성되어야 합니다. 응답의 id 속성에서 Microsoft Graph REST API /users 엔드포인트를 통해 Microsoft Entra 봇 개체 ID를 검색할 수 있습니다. Microsoft Graph를 사용하는 방법에 대한 자세한 내용은 Graph 탐색기를 사용해 보고 Graph SDK를 확인하세요.

기본 사용법

// 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 참조

MicrosoftTeamsAppIdentifier

Unknown

UnknownIdentifier는 미래 언어 교정을 위해 존재하며 이전 버전의 SDK에 있고 최근에 새 식별자 형식이 도입되었을 때 인터페이스가 발생할 수 있습니다. 서비스의 알 수 없는 식별자는 SDK의 UnknownIdentifier로 역직렬화됩니다.

기본 사용법

// create an identifier
let unknown = UnknownIdentifier("a raw id that originated in the service")

API 참조

UnknownIdentifier

CommunicationIdentifier 기본 프로토콜을 처리하는 방법

SDK에 전달하는 구체적인 형식에 대한 식별자를 생성하는 동안 SDK는 CommunicationIdentifier 프로토콜을 반환합니다. 구체적인 형식으로 쉽게 다시 다운 캐스팅할 수 있으며 패턴이 일치하는 switch-case 문을 제안합니다.

switch (communicationIdentifier)
{
    case let communicationUser as CommunicationUserIdentifier:
        print(#"Communication user: \(communicationUser.id)"#)
    case let teamsUser as MicrosoftTeamsUserIdentifier:
        print(#"Teams user: \(teamsUser.UserId)"#)
    case let phoneNumber as PhoneNumberIdentifier:
        print(#"Phone number: \(phoneNumber.PhoneNumber)"#)
    case let bot as MicrosoftBotIdentifier:
        print(#"Microsoft bot: \(bot.botId)"#)
    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;
}

원시 ID 표현

경우에 따라 식별자를 플랫 문자열로 직렬화해야 합니다. 예를 들어 데이터베이스 테이블에 식별자를 저장하거나 URL 매개 변수로 사용하려는 경우입니다.

이를 위해 식별자에는 RawId라는 다른 표현이 있습니다. 식별자는 항상 해당 원시 ID로 변환될 수 있으며 유효한 원시 ID는 항상 식별자로 변환될 수 있습니다.

Azure.Communication.Common 1.1.0 SDK는 다음 변환에 도움이 됩니다.

Swift

// get an identifier's raw Id
let rawId = communicationIdentifier.rawId;

// create an identifier from a given raw Id
let identifier = createCommunicationIdentifier(fromRawId: rawId);

잘못된 원시 ID는 SDK에서 UnknownIdentifier로 변환되며 모든 유효성 검사는 서비스 쪽에서만 발생합니다.

통신 사용자

CommunicationUserIdentifierID SDK 또는 REST API를 사용하여 만든 사용자 ID를 나타냅니다. 애플리케이션에서 Microsoft Teams 상호 운용성 또는 전화 통신 기능을 사용하지 않는 경우 사용되는 유일한 식별자입니다.

기본 사용법

// 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 참조

CommunicationUserIdentifier

Microsoft Teams 사용자

MicrosoftTeamsUserIdentifier은 Microsoft Entra 사용자 개체 ID를 가진 Teams 사용자를 나타냅니다. 응답의 id 속성에서 Microsoft Graph REST API /users 엔드포인트를 통해 Microsoft Entra 사용자 개체 ID를 검색할 수 있습니다. Microsoft Graph를 사용하는 방법에 대한 자세한 내용은 Graph 탐색기를 사용해 보고 Graph SDK를 확인하세요. 또는 사용자가 로그인하여 토큰을 획득한 후 ID를 ID 토큰 또는 Microsoft Entra 액세스 토큰에서 oid 클레임으로 찾을 수 있습니다.

기본 사용법

// 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 참조

MicrosoftTeamsUserIDentifier

전화번호

PhoneNumberIdentifier는 전화번호를 나타냅니다. 이 서비스는 전화 번호의 형식이 E.164 형식이라고 가정합니다.

기본 사용법

// create an identifier
PhoneNumberIdentifier phoneNumber = new PhoneNumberIdentifier("+112345556789");

API 참조

PhoneNumberIDentifier

Microsoft Teams 애플리케이션

MicrosoftTeamsAppIdentifier 인터페이스는 Microsoft Entra 봇 개체 ID를 사용하여 통화 큐 및 자동 전화 교환과 같은 Teams Voice 애플리케이션의 봇을 나타냅니다. Teams 애플리케이션은 리소스 계정으로 구성되어야 합니다. 응답의 id 속성에서 Microsoft Graph REST API /users 엔드포인트를 통해 Microsoft Entra 봇 개체 ID를 검색할 수 있습니다. Microsoft Graph를 사용하는 방법에 대한 자세한 내용은 Graph 탐색기를 사용해 보고 Graph SDK를 확인하세요.

기본 사용법

// 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 참조

MicrosoftTeamsAppIdentifier

Unknown

UnknownIdentifier는 미래 언어 교정을 위해 존재하며 이전 버전의 SDK에 있고 최근에 새 식별자 형식이 도입되었을 때 인터페이스가 발생할 수 있습니다. 서비스의 알 수 없는 식별자는 SDK의 UnknownIdentifier로 역직렬화됩니다.

기본 사용법

// create an identifier
UnknownIdentifier unknown = new UnknownIdentifier("a raw id that originated in the service");

API 참조

UnknownIdentifier

CommunicationIdentifier 기본 클래스를 처리하는 방법

SDK에 전달하는 구체적인 형식에 대한 식별자를 생성하는 동안 SDK는 추상 CommunicationIdentifier를 반환합니다. 구체적인 형식으로 다시 다운 캐스팅할 수 있습니다.

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 PhoneNumberIdentifier) {
    Log.i(tag, "Phone number: " + ((PhoneNumberIdentifier)communicationIdentifier).getPhoneNumber());
}
else if (communicationIdentifier instanceof MicrosoftBotIdentifier) {
    Log.i(tag, "Microsoft bot: " + ((MicrosoftBotIdentifier)communicationIdentifier).getBotId());
}
else if (communicationIdentifier instanceof UnknownIdentifier) {
    Log.i(tag, "Unkown user: " + ((UnknownIdentifier)communicationIdentifier).getId());
}
else {
    // be careful here whether you want to throw because a new SDK version
    // can introduce new identifier types
}

원시 ID 표현

경우에 따라 식별자를 플랫 문자열로 직렬화해야 합니다. 예를 들어 데이터베이스 테이블에 식별자를 저장하거나 URL 매개 변수로 사용하려는 경우입니다.

이를 위해 식별자에는 RawId라는 다른 표현이 있습니다. 식별자는 항상 해당 원시 ID로 변환될 수 있으며 유효한 원시 ID는 항상 식별자로 변환될 수 있습니다.

azure-communication-common 1.1.0 SDK는 다음 변환에 도움이 됩니다.

// get an identifier's raw Id
String rawId = communicationIdentifier.getRawId();

// create an identifier from a given raw Id
CommunicationIdentifier identifier = CommunicationIdentifier.fromRawId(rawId);

잘못된 원시 ID는 SDK에서 UnknownIdentifier로 변환되며 모든 유효성 검사는 서비스 쪽에서만 발생합니다.

REST API에서 식별자는 다형 형식입니다. JSON 개체와 구체적인 식별자 하위 형식에 매핑되는 속성을 생성합니다. 편의 및 이전 버전과의 호환성을 위해 kindrawId 속성은 요청에서 선택 사항이지만 서비스 응답에 채워집니다.

통신 사용자

CommunicationUserIdentifierModelID SDK 또는 REST API를 사용하여 만든 사용자 ID를 나타냅니다. 애플리케이션에서 Microsoft Teams 상호 운용성 또는 전화 통신 기능을 사용하지 않는 경우 사용되는 유일한 식별자입니다.

기본 사용법


// 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"
    }
}

참가자를 추가하기 위한 채팅의 REST API에 식별자가 포함된 요청에 대한 예제와 채팅 메시지 가져오기 아래에 식별자가 있는 응답의 예제를 찾을 수 있습니다.

API 참조

CommunicationUserIDentifierModel

Microsoft Teams 사용자

MicrosoftTeamsUserIdentifierModel은 Microsoft Entra 사용자 개체 ID를 가진 Teams 사용자를 나타냅니다. 응답의 id 속성에서 Microsoft Graph REST API /users 엔드포인트를 통해 Microsoft Entra 사용자 개체 ID를 검색할 수 있습니다. Microsoft Graph를 사용하는 방법에 대한 자세한 내용은 Graph 탐색기를 사용해 보고 Graph SDK를 확인하세요. 또는 사용자가 로그인하여 토큰을 획득한 후 ID를 Microsoft Entra 토큰 또는 Microsoft Entra 액세스 토큰에서 oid 클레임으로 찾을 수 있습니다.

기본 사용법

// request
{
    "microsoftTeamsUser": {
        "userId": "daba101a-91c5-44c9-bb9b-e2a9a790571a"
    }
}

// response
{
    "kind": "microsoftTeamsUser",
    "rawId": "8:orgid:daba101a-91c5-44c9-bb9b-e2a9a790571a",
    "microsoftTeamsUser": {
        "userId": "daba101a-91c5-44c9-bb9b-e2a9a790571a"
    }
}


// if you're not operating in the public cloud, you must also pass the right Cloud type in a request
{
    "microsoftTeamsUser": {
        "userId": "daba101a-91c5-44c9-bb9b-e2a9a790571a",
        "cloud": "gcch"
    }
}

// response
{
    "kind": "microsoftTeamsUser",
    "rawId": "8:gcch:daba101a-91c5-44c9-bb9b-e2a9a790571a",
    "microsoftTeamsUser": {
        "userId": "daba101a-91c5-44c9-bb9b-e2a9a790571a",
        "isAnonymous": false,
        "cloud": "gcch"
    }
}

API 참조

MicrosoftTeamsUserIDentifierModel

전화번호

PhoneNumberIdentifierModel는 전화번호를 나타냅니다. 이 서비스는 전화 번호의 형식이 E.164 형식이라고 가정합니다.

기본 사용법

// request
{
    "phoneNumber": {
        "value": "+112345556789"
    }
}

// response
{
    "kind": "phoneNumber",
    "rawId": "4:+112345556789",
    "phoneNumber": {
        "value": "+112345556789"
    }
}

API 참조

PhoneNumberIDentifierModel

Microsoft Teams 애플리케이션

MicrosoftTeamsAppIdentifierModel은 Microsoft Entra 봇 개체 ID를 사용하여 통화 큐 및 자동 전화 교환과 같은 Teams Voice 애플리케이션의 봇을 나타냅니다. Teams 애플리케이션은 리소스 계정으로 구성되어야 합니다. 응답의 id 속성에서 Microsoft Graph REST API /users 엔드포인트를 통해 Microsoft Entra 봇 개체 ID를 검색할 수 있습니다. Microsoft Graph를 사용하는 방법에 대한 자세한 내용은 Graph 탐색기를 사용해 보고 Graph SDK를 확인하세요.

기본 사용법

// request
{
    "microsoftTeamsApp": {
        "appId": "45ab2481-1c1c-4005-be24-0ffb879b1130"
    }
}

// response
{
    "kind": "microsoftTeamsApp",
    "rawId": "28:orgid:45ab2481-1c1c-4005-be24-0ffb879b1130",
    "microsoftTeamsApp": {
        "appId": "45ab2481-1c1c-4005-be24-0ffb879b1130"
    }
}


// if you're not operating in the public cloud, you must also pass the right Cloud type in a request
{
    "microsoftTeamsApp": {
        "appId": "45ab2481-1c1c-4005-be24-0ffb879b1130",
        "cloud": "gcch"
    }
}

// response
{
    "kind": "microsoftTeamsApp",
    "rawId": "28:gcch:45ab2481-1c1c-4005-be24-0ffb879b1130",
    "microsoftTeamsApp": {
        "appId": "45ab2481-1c1c-4005-be24-0ffb879b1130",
        "cloud": "gcch"
    }
}

API 참조

MicrosoftTeamsAppIdentifierModel

Unknown

서비스에 새 식별자가 도입되면 이전 API 버전인 경우 CommunicationIdentifierModel로 다운그레이드됩니다.

기본 사용법

// request
{
    "rawId": "a raw id that originated in the service"
}

// response
{
    "kind": "unknown",
    "rawId": "a raw id that originated in the service"
}

API 참조

CommunicationIDentifierModel

응답에서 CommunicationIdentifierModel를 처리하는 방법

최근 API 버전은 다음을 구분하는 데 사용할 수 있는 kind 속성을 채웁니다.

switch (communicationIdentifier.kind)
{
    case "communicationUser":
        console.log(`Communication user: ${communicationIdentifier.communicationUser.id}`);
        break;
    case "microsoftTeamsUser":
        console.log(`Teams user: ${communicationIdentifier.microsoftTeamsUser.userId}`);
        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;
}

이전 API 버전에서는 kind 속성이 누락되어 올바른 하위 속성이 있는지 확인해야 합니다.

if (communicationIdentifier.communicationUser) {
    console.log(`Communication user: ${communicationIdentifier.communicationUser.id}`);
} else if (communicationIdentifier.microsoftTeamsUser) {
    console.log(`Teams user: ${communicationIdentifier.microsoftTeamsUser.userId}`);
} else if (communicationIdentifier.phoneNumber) {
    console.log(`Phone number: ${communicationIdentifier.phoneNumber.value}`);
} else {
    console.log(`Unknown: ${communicationIdentifier.rawId}`);
}

원시 ID 표현

경우에 따라 식별자를 플랫 문자열로 직렬화해야 합니다. 예를 들어 데이터베이스 테이블에 식별자를 저장하거나 URL 매개 변수로 사용하려는 경우입니다.

이를 위해 식별자에는 RawId라는 다른 표현이 있습니다. 식별자는 항상 해당 원시 ID로 변환될 수 있으며 유효한 원시 ID는 항상 식별자로 변환될 수 있습니다.

Azure SDK를 사용하는 경우 변환에 도움이 됩니다. REST API를 직접 사용하는 경우 아래에 설명된 대로 원시 ID를 수동으로 생성해야 합니다.

통신 사용자

식별자:

{
    "communicationUser": {
        "id": "[communicationUserId]"
    }
}

원시 ID:

[communicationUserId]

원시 ID는 communicationUser.id와 동일합니다.

Microsoft Teams 사용자

식별자:

{
    "microsoftTeamsUser": {
        "userId": "[aadUserId]"
    }
}

원시 ID:

8:orgid:[aadUserId]

원시 ID는 8:orgid: 접두사가 있는 Microsoft Entra 사용자 개체 ID입니다.

식별자:

{
    "microsoftTeamsUser": {
        "userId": "[aadUserId]",
        "cloud": "gcch"
    }
}

원시 ID:

8:gcch:[aadUserId]

원시 ID는 클라우드 환경에 따라 8:gcch: 또는 8:dod: 접두사가 있는 Microsoft Entra 사용자 개체 ID입니다.

식별자:

{
    "microsoftTeamsUser": {
        "userId": "[visitorUserId]",
        "isAnonymous": true
    }
}

원시 ID:

8:teamsvisitor:[visitorUserId]

원시 ID는 8:teamsvisitor: 접두사가 있는 Azure AD 사용자 개체 ID입니다. Teams 방문자 ID는 모임 액세스를 사용하도록 설정하기 위해 Teams에서 생성하는 임시 ID입니다.

전화번호

식별자:

{
    "phoneNumber": {
        "value": "+1123455567"
    }
}

원시 ID:

4:+1123455567

원시 ID는 4: 접두사가 붙은 E.164 형식의 전화번호입니다.

Unknown

식별자:

{
    "rawId": "[unknown identifier id]"
}

원시 ID:

[unknown identifier id]

원시 ID가 잘못된 경우 서비스는 요청에 실패합니다.

다음 단계