# Creating a resource account and assigning a Direct Routing DID

Due to Teams Direct Routing being a fairly new product theres a few items that still have to be configured via PowerShell. By default Microsoft doesn't allow you to assign a DID from a Direct Routing trunk to a Resource account for use with a Queue or IVR configuration.

You can get around this limitation by using the "Skype For Business" and *"*&#x41;zureAD" (MSOnline) PowerShell plugins.

## Prerequisites

You will need to install some modules into PowerShell before you begin. You may already have these modules, if you have them installed already it will notify you.&#x20;

1. ~~Install the "Skype for Business PowerShell plugin" -~~ [~~https://www.microsoft.com/en-au/download/details.aspx?id=39366~~](https://www.microsoft.com/en-au/download/details.aspx?id=39366)
2. Install the Microsoft Teams Module - **Install-Module MicrosoftTeams**
3. Run this command to get the "AzureAD" plugin - **Install-Module MSOnline**

{% hint style="danger" %}
Microsoft have discontinued the use of the Skype for Business Powershell plugin, you will need to install the new Teams module instead
{% endhint %}

## Connecting to the Cloud Services

To create the resource account we will need to connect to Skype for Business and AzureAD modules so we can run the commands we need. It will make you login twice as we will be connecting to two different services for Microsoft Teams.

Connect to Microsoft Teams with the below commands, when connecting you will be prompted for the Teams Admin credentials. Any user with Admin access should be able to login.

```
Import-Module MicrosoftTeams
Connect-MicrosoftTeams
```

Import the MSOnline module and connect to AzureAD with the below command

```
Import-Module MSOnline
Connect-MsolService
```

To verify you are connected successfully you can run the below commands, they should return user information for you

```
Get-CSOnlineUser | select DisplayName ## Skype for Business Command
Get-MsolUser ## AzureAD Command
```

## Creating the resource account/s & Assigning DIDs

Now that we are connected we can proceed with creating the resource accounts, some functions can take a few moments to sync with Microsoft's servers once they're run so if you encounter not found errors try again after a few minutes.

### 1 - Create the Resource Account

Run the below commads within the PowerShell window, change the application ID to suit one of the two below (depending on what you want to deploy). Adding these application ID's is the same as pressing "AutoAttendant" or "Call Queue" in the Admin Panel.

Auto-Attendant ID - ce933385-9390-45d1-9512-c8d228074e07\
Call Queue ID - 11cd3e2e-fccb-42ad-ad00-878b93575e07

{% hint style="warning" %}
You will need to modify the below command with some information specific to your deployment, anything surrounded by "<" and ">" will need to be changed
{% endhint %}

```
New-CsOnlineApplicationInstance -UserPrincipalName <resource_emailaddress> -ApplicationId “<type_id>” -DisplayName "<resource_displayname>"

## Here is an example of a Call Queue account
New-CsOnlineApplicationInstance -UserPrincipalName callqueue@contoso.com -ApplicationId “11cd3e2e-fccb-42ad-ad00-878b93575e07” -DisplayName "Resource Account - Call Queue 1"
```

Once that is created we need to assign a location to the account.

```
Set-MsolUser -UserPrincipalName "<resource_emailaddress>" -UsageLocation AU

## EXAMPLE
Set-MsolUser -UserPrincipalName "callqueue@contoso.com" -UsageLocation AU
```

You will then need to assign a licence to it, you can find what licences you have with the below command. You can also assign a  "Phone System - **Virtual User**" licence if you have them.

```
## Use this to get your licence type/s
Get-MsolAccountSku

## Grab the value in the "AccountSkuID" column and run the below command
Set-MsolUserLicense -UserPrincipalName <resource_emailaddress> -AddLicenses "<accountSkuId>"

## EXAMPLE
Set-MsolUserLicense -UserPrincipalName callqueue@contoso.com -AddLicenses "reseller-account:ENTERPRISEPREMIUM"
```

### Assigning DIDs to Resource Accounts

Once you have created your Resource Account, assigned it a location and given it a licence you can then assign a DID to the account.

```
## Ensure the DID isn't in use anywhere else, if it is you will get an error
## as it cannot exist twice

Set-CsOnlineApplicationInstance -Identity "<resource_emailaddress>" -OnPremPhoneNumber +61<fnn>

## EXAMPLE
Set-CsOnlineApplicationInstance -Identity "callqueue@contoso.com" -OnPremPhoneNumber +61289998000 
```

Once that command completes successfully you should be able to login to the Teams admin panel, navigate to **Org-Wide Settings >> Resource Accounts** and in the table that appears you should see the DID you just assigned.

![](/files/-MCBPxu4AzLYmpun1U_D)

You can now assign this Resource account to either a Auto-Attendant or a Call Queue (depending on the Application ID you selected)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kb.hostednetwork.com.au/support/services/voice-over-ip-voip/general/trunks-for-microsoft-teams/creating-a-resource-account-and-assigning-a-direct-routing-did.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
