MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.28k stars 21.45k forks source link

C# sample code has errors #117109

Closed vbandi closed 9 months ago

vbandi commented 11 months ago

[Enter feedback here] The C# Sample code has multiple errors. This is what worked for me:

using System;
using Azure.Communication.Identity;
using Azure;
using System.Collections.Generic;
using Azure.Communication.NetworkTraversal;

namespace RelayTokenQuickstart
{
    class Program
    {
        static async Task Main(string[] args)
        {
            Console.WriteLine("Azure Communication Services - User Relay Token Quickstart");

            // This code demonstrates how to fetch your connection string
            // from an environment variable.
            string connectionString =
                "CONNECTION_STRING_HERE";
            var client = new CommunicationIdentityClient(connectionString);

            var identityResponse = (await client.CreateUserAsync());
            var identity = identityResponse.Value;
            Console.WriteLine($"\nCreated an identity with ID: {identity.Id}");

            var relayClient = new CommunicationRelayClient(connectionString);

            Response<CommunicationRelayConfiguration> turnTokenResponse = await relayClient.GetRelayConfigurationAsync(identity);
            DateTimeOffset turnTokenExpiresOn = turnTokenResponse.Value.ExpiresOn;
            IReadOnlyList<CommunicationIceServer> iceServers = turnTokenResponse.Value.IceServers.AsReadOnly();
            Console.WriteLine($"Expires On: {turnTokenExpiresOn}");
            foreach (CommunicationIceServer iceServer in iceServers)
            {
                foreach (string url in iceServer.Urls)
                {
                    Console.WriteLine($"TURN Url: {url}");
                }
                Console.WriteLine($"TURN Username: {iceServer.Username}");
                Console.WriteLine($"TURN Credential: {iceServer.Credential}");
            }
        }
    }
}

Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

Naveenommi-MSFT commented 11 months ago

@vbandi Thanks for your feedback! We will investigate and update as appropriate.

Venkateshdodda-MSFT commented 11 months ago

@vbandi I have assigned this to content author @sphenry to review and help us in updating the documentation accordingly.

lisaleehan commented 9 months ago

@Venkateshdodda-MSFT @mumurug-MSFT Please close this ticket as TURN is currently deprecated and will be removed completely in March

Venkateshdodda-MSFT commented 9 months ago

@vbandi Thanks for bringing this to our attention. We will now close this issue as @lisaha0713 mentioned that TURN is currently deprecated and respective documentations will get updated accordingly.

If there are further questions regarding this matter, please reopen it and we will gladly continue the discussion.