Local emulator to run Azure Communication Services client SDKs without having to provision an Azure Communication Services resource.
Make sure you have the .NET Core SDK installed, download the latest AcsEmulatorCLI Release and then run from a terminal:
dotnet tool install -g --add-source [downloadFolder] AcsEmulatorCLI --version [nupkgVersion]
Usage:
acs-emulator [command] [options]
Commands:
Command | Description |
---|---|
--version |
Show version information |
-?, -h, --help |
Show help and usage information |
run |
Run the emulator. |
openApi |
Open the emulator's API in Swagger UI. |
openDB |
Open the emulator's sqlite database. |
openUI |
Open the emulator UI. |
clean |
Clean all data and reset the emulator state. |
connectionString |
Get the ACS connection string for the emulator. |
repo |
Open code repository. |
-
You can use the
Try it
feature in the Swagger editor underhttps://localhost/swagger
to send requests against the API -
Use
"endpoint=https://localhost/;accessKey=pw=="
as your connection string when instantiating Azure Communication Services SDK service clients. -
Use the Identity SDK with the localhost connection string and create users and tokens as usual. Use the created token to instantiate the Chat SDK.
-
When running the JavaScript SDKs with Node.JS add
NODE_TLS_REJECT_UNAUTHORIZED="0"
as an env variable -
You can also use endpoint
https://localhost/
to run the Live Preview of the UI library's Chat composite. First, create two users with tokens and use one of the users to create a chat thread with the other user. Then, you can open two tabs side by side and fill in the the respective user, token, thread id and endpoint for each. -
You can browse the emulator data under
http://localhost:3000
- Make sure
serve
is installed globally on your machine:npm i -g serve
- Make sure
- For inspecting the DB data directly, we recommend to install DB Browser for SQLite and use it to open the
AcsEmulator.db
file
-
Install the
dotnet ef
tool: Rundotnet tool install --global dotnet-ef
Link for details -
Run
dotnet ef database update
to update your local copy of theAcsEmulator.db
in case new migrations were added. -
Build and run the
AcsEmulatorApi
project -
Build the emulator UI by navigating to
acs-emulator-ui
, then runnpm install
andnpm run start
-
To build a new version of the CLI tool, first build the
acs-emulator-ui
withnpm run build
to build production bundles. Then build theAcsEmulatorCLI
project (in theRelease
flavor) -
For inspecting the DB data directly, we recommend to install DB Browser for SQLite and use it to open the
AcsEmulator.db
file -
To reset the emulator entirely and clear its data and state, delete the
AcsEmulator.db
file
The URL for establishing the real-time notification channel, is unfortunately hard-coded in the Azure SDK. To enable real-time notifications in the emulator follow these steps (requires rebuilding the emulator from source):
-
Add
127.0.0.1 go.trouter.teams.microsoft.com
to your machine's hosts file to redirect the SDK's hard-coded URL to your localhost. -
Run
createSelfSignedCert.ps1
-
Install the generated
acsEmulator_selfSigned.pfx
in your certificate store under Trusted Root Certification Authorities using passwordmypassword
. Please uninstall the cert when no longer needed, we're hoping to get rid of the need to install a self-signed cert soon and fully rely on the ASP.NET Core HTTPS development certificate instead. -
Relaunch your browser to load the newly installed root certificate.
-
Add the following as a top property of
appsettings.json
:
"Kestrel": {
"Endpoints": {
"HttpsInlineCertFile": {
"Url": "https://localhost",
"Certificate": {
"Path": "acsEmulator_selfSigned.pfx",
"Password": "mypassword"
}
}
}
},
-
Rebuild and launch
AcsEmulatorAPI
. -
Restart all browsers to load the new root cert.
-
Run the
AcsEmulatorApi
project to start the emulator.
Now, the Chat SDK can establish a real-time notification channel which is backed by a websocket connection in the emulator's ASP .NET Core service.
- Only a subset of APIs have been implemented so far:
/identities
/chat
/email
/sms
- EventGrid events for Sms
- All server/control-plane APIs are unauthenticated (HMAC / AAD is ignored)
- API versioning is ignored, the implemented APIs are trying to be on a recent version
/chat
APIs are incomplete- token scope
chat
is not enforced - read receipts aren't implemented
- only
messageReceived
and typing real-time notifications are implemented so far
- token scope