Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure com service fix #60

Open
wants to merge 43 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
8b4cc58
ChatQuickstart
lookinnovative Jun 25, 2022
3f1937e
AccessTokensQuickstart
lookinnovative Jun 25, 2022
6ceac4d
CommunicationsAccessTokensQuickstart
lookinnovative Jun 25, 2022
b750384
update
lookinnovative Jun 25, 2022
3b6f849
modified
lookinnovative Jun 26, 2022
286bb4f
modified
lookinnovative Jun 26, 2022
4ccb2bf
ADquickstart
lookinnovative Jun 28, 2022
9feb704
send-email
lookinnovative Jun 28, 2022
36d2419
add-chat
lookinnovative Aug 10, 2022
013f548
send-email
lookinnovative Aug 11, 2022
96d7144
Merge branch 'main' of https://github.com/lookinnovative/communicatio…
lookinnovative Aug 11, 2022
8f96956
send-email
lookinnovative Aug 11, 2022
85a94cb
send-email
lookinnovative Aug 11, 2022
2ed13b8
outbound-call
lookinnovative Aug 11, 2022
a17a14e
calling-quickstart
lookinnovative Aug 12, 2022
3f2ed42
calling-quickstart
lookinnovative Aug 12, 2022
da62889
programcs
lookinnovative Aug 12, 2022
0c4279c
commit
lookinnovative Aug 12, 2022
aeecf66
csproj
lookinnovative Aug 12, 2022
b2dd637
changes
lookinnovative Aug 12, 2022
b004847
calling-quickstart
lookinnovative Aug 12, 2022
8f1d668
accesstoken
lookinnovative Aug 12, 2022
7909ada
sms
lookinnovative Aug 12, 2022
af94384
sms-send
lookinnovative Aug 14, 2022
f1cb131
version10
lookinnovative Aug 14, 2022
e6d8893
debug
lookinnovative Aug 14, 2022
0ff45d8
debugext
lookinnovative Aug 14, 2022
03b2380
voice-calling
lookinnovative Aug 15, 2022
060d89f
calling-quickstart-app
lookinnovative Aug 15, 2022
011e722
video-call
lookinnovative Aug 15, 2022
92e1193
launch
lookinnovative Aug 16, 2022
2267b2d
integratedTerminal
lookinnovative Aug 16, 2022
aa47dbb
app-client-id
lookinnovative Aug 28, 2022
f302494
ChatQuickStart
lookinnovative Aug 28, 2022
0f71d10
SendEmail
lookinnovative Aug 28, 2022
63c7d9c
authenticate
lookinnovative Aug 28, 2022
8423551
Merge branch 'Azure-Samples:main' into main
lookinnovative Sep 22, 2022
c86a7e9
code Fix
pandeys1004 Oct 31, 2022
50b0553
Merge branch 'main' into Azure-Com-Service-Fix
lookinnovative Oct 31, 2022
985330a
Azure com service fix (#1)
lookinnovative Nov 14, 2022
40606b9
Merge branch 'Azure-Samples:main' into main
lookinnovative Nov 14, 2022
5f92639
testpush
pandeys1004 Nov 14, 2022
6a8ecef
Merge branch 'main' into Azure-Com-Service-Fix
pandeys1004 Nov 14, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
12 changes: 11 additions & 1 deletion AccessTokensQuickstart/AccessTokensQuickstart.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<LangVersion>latestmajor</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<LangVersion>latestmajor</LangVersion>
</PropertyGroup>
<ItemGroup>

<PackageReference Include="Azure.Communication.Identity" Version="1.2.0" />
<PackageReference Include="Azure.Identity" Version="1.4.1" />

</ItemGroup>

</Project>
25 changes: 25 additions & 0 deletions AccessTokensQuickstart/AccessTokensQuickstart.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 25.0.1703.8
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AccessTokensQuickstart", "AccessTokensQuickstart.csproj", "{E61AC55E-AEA3-4A07-80AD-409058E5056F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E61AC55E-AEA3-4A07-80AD-409058E5056F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E61AC55E-AEA3-4A07-80AD-409058E5056F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E61AC55E-AEA3-4A07-80AD-409058E5056F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E61AC55E-AEA3-4A07-80AD-409058E5056F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2B69051C-5768-4328-8468-7A61CA0182A4}
EndGlobalSection
EndGlobal
50 changes: 8 additions & 42 deletions AccessTokensQuickstart/Program.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using System;
using Azure.Identity;
using Azure.Communication.Identity;
using Azure.Core;
using Azure.Communication;
using Azure;


namespace AccessTokensQuickstart
{
Expand All @@ -12,61 +9,30 @@ class Program
static async System.Threading.Tasks.Task Main(string[] args)
{
Console.WriteLine("Azure Communication Services - Access Tokens Quickstart");

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

// This code demonstrates how to fetch your endpoint and access key
// This code demonstrates how to retrieve your connection string
// from an environment variable.
/*string endpoint = Environment.GetEnvironmentVariable("COMMUNICATION_SERVICES_ENDPOINT");
string accessKey = Environment.GetEnvironmentVariable("COMMUNICATION_SERVICES_ACCESSKEY");
var client = new CommunicationIdentityClient(new Uri(endpoint), new AzureKeyCredential(accessKey));*/
//string connectionString = Environment.GetEnvironmentVariable("https://verizann-media.communication.azure.com/;accesskey=EQHWAYFO9E0NNcj8OZEFHcVtFWUa1EBEV4tsgX1ej53kJjv4v9ZgBLVotnwhKRtjTxdIf2UEq4xoJ5n/on5IYA==");
string connectionString = "endpoint=https://verizann-media.communication.azure.com/;accesskey=EQHWAYFO9E0NNcj8OZEFHcVtFWUa1EBEV4tsgX1ej53kJjv4v9ZgBLVotnwhKRtjTxdIf2UEq4xoJ5n/on5IYA==";

// Update documentation with URI details
/*TokenCredential tokenCredential = new DefaultAzureCredential();
string endPoint = Environment.GetEnvironmentVariable("COMMUNICATION_SERVICES_ENDPOINT");
var client = new CommunicationIdentityClient(new Uri(endPoint), tokenCredential);*/
var client = new CommunicationIdentityClient(connectionString);

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

// Issue an access token with a validity of 24 hours and the "voip" scope for an identity
var tokenResponse = await client.GetTokenAsync(identity, scopes: new[] { CommunicationTokenScope.VoIP });

// Get the token from the response
var token = tokenResponse.Value.Token;
var expiresOn = tokenResponse.Value.ExpiresOn;
Console.WriteLine($"\nIssued an access token with 'voip' scope that expires at {expiresOn}:");
Console.WriteLine(token);

// Issue an access token with a validity of an hour and the "voip" scope for an identity
TimeSpan tokenExpiresIn = TimeSpan.FromHours(1);
CommunicationTokenScope[] scopes = new[] { CommunicationTokenScope.VoIP };
tokenResponse = await client.GetTokenAsync(identity, scopes, tokenExpiresIn);

// Issue an identity and an access token with a validity of 24 hours and the "voip" scope for the new identity
var identityAndTokenResponse = await client.CreateUserAndTokenAsync(scopes: new[] { CommunicationTokenScope.VoIP });
identity = identityAndTokenResponse.Value.User;
token = identityAndTokenResponse.Value.AccessToken.Token;
expiresOn = identityAndTokenResponse.Value.AccessToken.ExpiresOn;
Console.WriteLine($"\nCreated an identity with ID: {identity.Id}");
// Write the token details to the screen
Console.WriteLine($"\nIssued an access token with 'voip' scope that expires at {expiresOn}:");
Console.WriteLine(token);

// Refresh access tokens
var identityToRefresh = new CommunicationUserIdentifier(identity.Id);
var refreshTokenResponse = await client.GetTokenAsync(identityToRefresh, scopes: new[] { CommunicationTokenScope.VoIP });

// Revoke access tokens
await client.RevokeTokensAsync(identity);
Console.WriteLine($"\nSuccessfully revoked all access tokens for identity with ID: {identity.Id}");

// Delete an identity
await client.DeleteUserAsync(identity);
Console.WriteLine($"\nDeleted the identity with ID: {identity.Id}");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<LangVersion>latestmajor</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<LangVersion>latestmajor</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Communication.Identity" Version="1.0.1" />
<PackageReference Include="Azure.Communication.Sms" Version="1.0.1" />
<PackageReference Include="Azure.Identity" Version="1.6.0" />
<PackageReference Include="Microsoft.Extensions.Azure" Version="1.2.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 25.0.1703.5
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ActiveDirectoryAuthenticationQuickstart", "ActiveDirectoryAuthenticationQuickstart.csproj", "{AB20935F-2B8E-4CCA-A151-F4DCF6BF0D97}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AB20935F-2B8E-4CCA-A151-F4DCF6BF0D97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AB20935F-2B8E-4CCA-A151-F4DCF6BF0D97}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AB20935F-2B8E-4CCA-A151-F4DCF6BF0D97}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AB20935F-2B8E-4CCA-A151-F4DCF6BF0D97}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {47408880-FC5E-4A1D-8720-61A3A9C0C6B9}
EndGlobalSection
EndGlobal
54 changes: 54 additions & 0 deletions ActiveDirectoryAuthenticationQuickstart/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using Azure.Identity;
using Azure.Communication.Identity;
using Azure.Communication.Sms;
using Azure.Core;
using Azure;
using System.Data;

class Program
{
private DefaultAzureCredential credential = new DefaultAzureCredential();
static void Main(string[] args)
{
// You can find your endpoint and access key from your resource in the Azure portal
// e.g. "https://<RESOURCE_NAME>.communication.azure.com";
Uri endpoint = new("https://verizann-media.communication.azure.com/");
string conString = "endpoint=https://verizann-media.communication.azure.com/;accesskey=EQHWAYFO9E0NNcj8OZEFHcVtFWUa1EBEV4tsgX1ej53kJjv4v9ZgBLVotnwhKRtjTxdIf2UEq4xoJ5n/on5IYA==";
// We need an instance of the program class to use within this method.
Program instance = new();

Console.WriteLine("Retrieving new Access Token, using Service Principals");
Response<AccessToken> response = instance.CreateIdentityAndGetTokenAsync(conString);
Console.WriteLine($"Retrieved Access Token: {response.Value.Token}");

Console.WriteLine("Sending SMS using Service Principals");

// You will need a phone number from your resource to send an SMS.
SmsSendResult result = instance.SendSms(endpoint, "+18772178780", "+14048386995", "Hello from Service Principals");
Console.WriteLine($"Sms id: {result.MessageId}");
Console.WriteLine($"Send Result Successful: {result.Successful}");
}
public Response<AccessToken> CreateIdentityAndGetTokenAsync(string conString)
{
var client = new CommunicationIdentityClient(conString);
var identityResponse = client.CreateUser();
var identity = identityResponse.Value;

var tokenResponse = client.GetToken(identity, scopes: new[] { CommunicationTokenScope.VoIP });

return tokenResponse;
}
public SmsSendResult SendSms(Uri resourceEndpoint, string from, string to, string message)
{
SmsClient smsClient = new SmsClient(resourceEndpoint, this.credential);
SmsSendResult sendResult = smsClient.Send(
from: from,
to: to,
message: message,
new SmsSendOptions(enableDeliveryReport: true) // optional
);

return sendResult;
}

}
72 changes: 64 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,69 @@
## [project-title] Changelog
## Azure Communication Services

<a name="x.y.z"></a>
# x.y.z (yyyy-mm-dd)
# SendSmsMessage(27-oct-2022)

*Features*
* ...
* Send SMS by using Azure communication

*Bug Fixes*
* ...
*Fixes done*
* 1- Migrated the entire project to dotnet core 3.1

*Breaking Changes*
* ...
# Send and Email ACS(27-oct-2022)

*Features*
* Send Email by using Azure communication

*Fixes done*
* 1- Migrated the entire project to dotnet core 3.1

# Identity Access Management(27-oct-2022)

*Features*
* Identity Access management ensures that right people and job roles in organization can access the resources.

*Fixes done*
* 1- Migrated the entire project to dotnet core 3.1
* 2- Connected communication to created domain in azure

# Add Chat(27-oct-2022)

*Features*
* Provide chat solution using Azure

*Fixes done*
* 1- Migrated the entire project to dotnet core 3.1
* 2- Connected communication to created domain in azure

# Authentication using ADS(27-oct-2022)

*Features*
* Authenticating using ADS

*Fixes done*
* 1- Migrated the entire project to dotnet core 3.1
* 2- use api to authenticate instead tennet id , clientid and client secret.

# Create com resource(27-oct-2022)

*Features*
* creating communication services using Azure api

*Fixes done*
* 1- Migrated the entire project to dotnet core 3.1
* 2- use api to authenticate instead tennet id , clientid and client secret.
* 3- use interactive authentication way to create the com resource.

# Voice Calling(27-oct-2022)

*Features*
* voice calling web solution using azure

*Created from scratch*


# Video Calling(27-oct-2022)

*Features*
* Video calling web solution using azure

*Created from scratch*
20 changes: 20 additions & 0 deletions ChatQuickstart/ChatQuickstart.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<LangVersion>latestmajor</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<LangVersion>latestmajor</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Communication.Chat" Version="1.1.1" />
</ItemGroup>

</Project>
25 changes: 25 additions & 0 deletions ChatQuickstart/ChatQuickstart.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 25.0.1703.8
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChatQuickstart", "ChatQuickstart.csproj", "{E2A3C2A1-2B04-44F9-A351-5B7C5F3D32EB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E2A3C2A1-2B04-44F9-A351-5B7C5F3D32EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E2A3C2A1-2B04-44F9-A351-5B7C5F3D32EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E2A3C2A1-2B04-44F9-A351-5B7C5F3D32EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E2A3C2A1-2B04-44F9-A351-5B7C5F3D32EB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B81D7952-92F4-49EC-AA91-58FFD3B79215}
EndGlobalSection
EndGlobal
21 changes: 21 additions & 0 deletions ChatQuickstart/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Azure;
using Azure.Communication;
using Azure.Communication.Chat;
using System;

namespace ChatQuickstart
{
class Program
{
static async System.Threading.Tasks.Task Main(string[] args)
{
// Your unique Azure Communication service endpoint
Uri endpoint = new Uri("https://verizann-media.communication.azure.com");

CommunicationTokenCredential communicationTokenCredential = new CommunicationTokenCredential("eyJhbGciOiJSUzI1NiIsImtpZCI6IjEwNiIsIng1dCI6Im9QMWFxQnlfR3hZU3pSaXhuQ25zdE5PU2p2cyIsInR5cCI6IkpXVCJ9.eyJza3lwZWlkIjoiYWNzOjUyOWM3YjcyLTdjMzQtNGRkYi05ZTc4LTEzMThiZWJjMWU0ZF8wMDAwMDAxNC1iZmJjLTM0ZjEtZjZjNy01OTNhMGQwMGRlY2YiLCJzY3AiOjE3OTIsImNzaSI6IjE2NjY5ODE3MjkiLCJleHAiOjE2NjcwNjgxMjksImFjc1Njb3BlIjoidm9pcCIsInJlc291cmNlSWQiOiI1MjljN2I3Mi03YzM0LTRkZGItOWU3OC0xMzE4YmViYzFlNGQiLCJyZXNvdXJjZUxvY2F0aW9uIjoidW5pdGVkc3RhdGVzIiwiaWF0IjoxNjY2OTgxNzI5fQ.cqUmMbdTWmvIw8OqYEEq6WvCZgFo1sdnPzORgTByaoJPYwHFHvzOrBHymzm6GkVkC_2KHymEycz1bLyO3Ym0-yZjP5xAVi2SxXBPbmkjwiwRJByP1Vx73HscjKcmuOiuzafBOV8bHZzCDrMysgxdYu3D9RKltt02HwCMjSRGim67WPOCSh-pnt91Xq4XKBC56cSyOnoR5uqlgDZJFn0vuvt605n9WkTDHw-pfYduv7zJG8h_9-mQ96WtZw7Y3mGLBAPBQ3p114svODu_1oxa5bWknPOwTNi7igNw5X9bAkgX8jw0Zn7e2nkBvO-o3drov_AOkRQJpKY4skm5wu08nw");
ChatClient chatClient = new ChatClient(endpoint, communicationTokenCredential);
Console.WriteLine("Success");
}
}
}

Loading