This small project collects a few dotnet and projects that were created as part of a small example workflow for Microsoft Dynamics Sales. Ther are to applications currently available:
- A console application that shows all current accounts and assigns incremental indices to them.
- An Azure Function App project that can be hosted on Azure to provide (limited) CRUD functionality for accounts.
Currently, the console application runs exactly one command that assigns an incremental index to all accounts in alphabetical order, starting with a provided start index. Configuration details will be prompted when required, configuration files and environment variables are available for non-interactive scenarios.
The Function App offers basics CRUD functionality through multiple https triggers and a timer based function that assigns an incremental index to all accounts once a day.
Configuring the application can be done in the following ways:
- Configuration File (
appsettings.json
) - Environment Variables
- Command Line Arguments
- User Input (only if no value was previously provided)
For Azure Functions, only configuration via environment variables (i.e.: Application Settings) is available.
Please note that setting a value through one method above overwrites the previous values (order as stated above).
Mandatory:
- ConnectionConfiguration.Url: Url poiting to your Dynamics Sales Instance
- ConnectionConfiguration.UserName: Name of the user to login (only if AuthType is set to
OAuth
) - ConnectionConfiguration.Password: Password of the user required for login (only if AuthType is set to
OAuth
) - ConnectionConfiguration.AppId: Id oa registered service principal (only if AuthType is set to
ClientSecret
) - ConnectionConfiguration.ClientSecret: Secret of the registered service principal (only if AuthType is set to
ClientSecret
)
Optional:
- ConnectionConfiguration.AuthType Type of authentication used to login in. Available options are:
OAuth
andClientSecret
. Defaults toOAuth
- NonInteractive: If true, will immedtialey throw an error if a mandatory configuration value is not provided. Defaults to
false
.
Please note that nested configuration values (separated by .) need to be supplied based on the configuration method:
- Configuration File: Nested json properties, e.g.:
{ "StartupConfiguration": { "InitialAccountIndex": 123 } }
- Environment Variables: Requires colon
:
as a separator character, e.g.:--StartupConfiguration:InitialAccountIndex=123
- Command Line Arguments: Requires double underscores
__
as separator characters, e.g.:StartupConfiguration__InitialAccountIndex
123
{
"ConnectionConfiguration": {
"Url": "https://orgXXXX.crm4.dynamics.com/",
"UserName": "[email protected]",
"Password": "password123"
}
}
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
"NonInteractive": true,
"ConnectionConfiguration__Url": "https://org48XXXX.crm4.dynamics.com/",
"ConnectionConfiguration__AppId": "00000000-0000-0000-0000-000000000000",
"ConnectionConfiguration__ClientSecret": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"StartupConfiguration__InitialAccountIndex": 1,
"ConnectionConfiguration__AuthType": "ClientSecret"
}
}
The following extensions should be installed in order to successfully run and debug the console application:
ms-dotnettools.csharp
To run either of the applications, navigate to the Debug section of Visual Studio Code and choose the configuration you want to use for debugging, then hit F5.
To get started, clone the repository, open the project file src/DynamicsToolConsole.csproj
in Visual Studio and press F5 to start the application.