Skip to content

Commit a3e07dc

Browse files
Merge pull request #55 from Azure-Samples/add-arm-template-for-deployment
Implement the arm template custom deployment approach
2 parents f3a97e2 + 31117f6 commit a3e07dc

File tree

9 files changed

+32
-42
lines changed

9 files changed

+32
-42
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ jobs:
2929
# Build everything
3030
npm install
3131
npm run build
32-
7z a -tzip -r "auth-sample.zip" ./build/*
33-
# Delete output directory
34-
# rm -r "./build"
32+
7z a -tzip -r "auth-sample.zip" ./*
3533
3634
- name: Publish
3735
uses: softprops/action-gh-release@v1

deploy/azuredeploy.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@
6464
"displayName": "appSettings"
6565
},
6666
"properties": {
67-
"communicationServices_connectionString": "[listkeys(variables('commsName'), '2020-08-20-preview' ).primaryConnectionString]",
68-
"azureActiveDirectory_clientId": "",
69-
"azureActiveDirectory_clientSecret": "",
70-
"azureActiveDirectory_tenantId": ""
67+
"communicationServices__connectionString": "[listkeys(variables('commsName'), '2020-08-20-preview' ).primaryConnectionString]",
68+
"azureActiveDirectory__clientId": "",
69+
"azureActiveDirectory__clientSecret": "",
70+
"azureActiveDirectory__tenantId": ""
7171
}
7272
},
7373
{

src/appSettings.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"communicationServices": {
3+
"connectionString": "<your_acs_resource_connection_string>",
4+
"scopes": ["voip", "chat"]
5+
},
6+
"azureActiveDirectory": {
7+
"instance": "https://login.microsoftonline.com/",
8+
"clientId": "<your_server_app_client_id>",
9+
"clientSecret": "<your_server_app_client_secret>",
10+
"tenantId": "<your_server_app_tenant_id>"
11+
},
12+
"graph": {
13+
"extensionName": "com.contoso.identityMapping"
14+
}
15+
}

src/appSettings.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/services/aadService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*---------------------------------------------------------------------------------------------*/
55

66
import { Configuration, ConfidentialClientApplication } from '@azure/msal-node';
7-
import { appSettings } from '../appSettings';
7+
import * as appSettings from '../appSettings.json';
88

99
// Error messages
1010
const EXCHANGE_AAD_TOKEN_VIA_OBO_ERROR =

src/services/acsService.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ import { CommunicationUserIdentifier } from '@azure/communication-common';
77
import {
88
CommunicationAccessToken,
99
CommunicationIdentityClient,
10-
CommunicationUserToken
10+
CommunicationUserToken,
11+
TokenScope
1112
} from '@azure/communication-identity';
12-
import { appSettings } from '../appSettings';
13+
import * as appSettings from '../appSettings.json';
1314

1415
// Error messages
1516
const CREATE_ACS_USER_IDENTITY_ERROR = 'An error occured when creating an ACS user id';
@@ -19,6 +20,8 @@ const CREATE_ACS_USER_IDENTITY_TOKEN_ERROR =
1920
const DELETE_ACS_USER_IDENTITY_ERROR = 'An error occured when deleting an ACS user id';
2021
const EXCHANGE_AAD_TOKEN_ERROR = 'An error occured when exchanging an AAD token';
2122

23+
const communicationServicesScopes = appSettings.communicationServices.scopes.map((item) => item as TokenScope);
24+
2225
/**
2326
* Instantiate the identity client using the connection string.
2427
*
@@ -56,10 +59,7 @@ export const createACSToken = async (acsUserId: string): Promise<CommunicationAc
5659
try {
5760
// Issue an access token with the given scopes for an identity
5861
const communicationUserIdentifierObject: CommunicationUserIdentifier = { communicationUserId: acsUserId };
59-
const tokenResponse = await identityClient.getToken(
60-
communicationUserIdentifierObject,
61-
appSettings.communicationServices.scopes
62-
);
62+
const tokenResponse = await identityClient.getToken(communicationUserIdentifierObject, communicationServicesScopes);
6363

6464
return tokenResponse;
6565
} catch (error) {
@@ -96,7 +96,7 @@ export const createACSUserIdentityAndToken = async (): Promise<CommunicationUser
9696
const identityClient = createAuthenticatedClient();
9797
try {
9898
// Issue an identity and an access token with the given scopes for the new identity
99-
const identityTokenResponse = await identityClient.createUserAndToken(appSettings.communicationServices.scopes);
99+
const identityTokenResponse = await identityClient.createUserAndToken(communicationServicesScopes);
100100

101101
return identityTokenResponse;
102102
} catch (error) {

src/services/graphService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Used to fix the error "PolyFillNotAvailable: Library cannot function without fetch. So, please provide polyfill for it."
77
import 'isomorphic-fetch';
88
import { Client } from '@microsoft/microsoft-graph-client';
9-
import { appSettings } from '../appSettings';
9+
import * as appSettings from '../appSettings.json';
1010

1111
// Error messages
1212
const RETRIEVE_IDENTITY_MAPPING_ERROR = 'An error occured when retrieving the identity mapping information';

tests/services/graphService/getACSUserId.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/// <reference path="../../../node_modules/@types/jest/index.d.ts" />
88

99
import { Client, GraphRequest } from '@microsoft/microsoft-graph-client';
10-
import { appSettings } from '../../../src/appSettings';
10+
import * as appSettings from '../../../src/appSettings.json';
1111
import * as graphService from '../../../src/services/graphService';
1212
import { mockCommunicationAccessToken, mockAcsUserId } from '../../utils/mockData';
1313

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"moduleResolution": "node",
99
"sourceMap": true,
1010
"outDir": "build",
11-
"baseUrl": "."
11+
"baseUrl": ".",
12+
"resolveJsonModule": true
1213
},
1314
"include": ["src/**/*"]
1415
}

0 commit comments

Comments
 (0)