Saturday, September 2, 2023

Create Azure Communication identity and token using az cli


### Add the Azure Communication Services extension for Azure CLI by using the az extension command.

1. Add communication extension in az cli  (one time activity)
2. Connect to Azure using Az Cli
3. Create Identity using az communication user-identity 
4. Issue Identity Token for specific scope (voip, chat)


```sh 
az extension add --name communication
$acsName="< acs-Name >"
$resouceGroup="< Resource Group Name >"

$connection=az communication list-key --name $acsName --resource-group $resouceGroup  --query "primaryConnectionString"

$rawId=az communication user-identity user create --connection-string $connection  --query "rawId"

az communication identity token issue --scope chat voip  --user $rawId --connection-string $connection  --query "token"


Note:

#$rawId=az communication identity user create --connection-string $connection  --query "rawId"

#This command is implicitly deprecated because command group 'communication identity token' is deprecated and will be removed in a future release. Use communication user-identity token' instead.
```
___

Example :

```sh 

az extension add --name communication

az login

$acsName="aztds-acs-poc0821"

$resouceGroup="rg-aztds-acs-poc"

$connection=az communication list-key --name $acsName --resource-group $resouceGroup  --query "primaryConnectionString"

$rawId=az communication user-identity user create --connection-string $connection  --query "rawId"

az communication identity token issue --scope chat voip  --user $rawId --connection-string $connection  --query "token"

```

No comments:

Post a Comment