Skip to content

Commit

Permalink
Merge pull request #14 from InRule/UnifyAllArmTemplates
Browse files Browse the repository at this point in the history
Unify all arm templates
  • Loading branch information
lukecolburn authored Oct 24, 2019
2 parents f7fcfa1 + ffd76c4 commit 1250db7
Show file tree
Hide file tree
Showing 8 changed files with 557 additions and 2 deletions.
200 changes: 200 additions & 0 deletions Dynamics/InRule.Dynamics.Service.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appServiceName": {
"type": "string"
},
"relayName": {
"type": "string"
},
"orgUrl": {
"type": "string",
"defaultValue": "",
"metadata": {
"description": "Organization URL for the Dynamics instance used with the integration framework. This is just the root URL, ex: 'https://contoso.crm.dynamics.com'"
}
},
"appId": {
"type": "string",
"defaultValue": "",
"metadata": {
"description": "Azure app ID used for S2S authentication"
}
},
"appSecret": {
"type": "string",
"defaultValue": "",
"metadata": {
"description": "Secret value for app key used for S2S authentication"
}
},
"crmConnectionString": {
"type": "string",
"defaultValue": "",
"metadata": {
"description": "Connection string for the Dynamics CRM instance used with the integration framework. Refer to this link for more details and formatting: https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/xrm-tooling/use-connection-strings-xrm-tooling-connect"
}
},
"catalogUri": {
"type": "string"
},
"catalogUser": {
"type": "string"
},
"catalogPassword": {
"type": "string"
},
"createAppServicePlan": {
"type": "bool",
"defaultValue": true
},
"appServicePlanName": {
"type": "string",
"defaultValue": "[concat(parameters('appServiceName'),'Plan')]"
},
"appServicePlanSkuName": {
"type": "string",
"defaultValue": "B1",
"allowedValues": [
"F1",
"D1",
"B1",
"B2",
"B3",
"S1",
"S2",
"S3",
"P1",
"P2",
"P3",
"P4"
],
"metadata": {
"description": "Describes plan's pricing tier and capacity. Check details at https://azure.microsoft.com/en-us/pricing/details/app-service/"
}
},
"servicePlanResourceGroupName": {
"type": "string",
"defaultValue": "[resourceGroup().name]"
},
"inRuleVersion": {
"type": "string",
"defaultValue": "5.4.3"
},
"appInsightsInstrumentationKey": {
"type": "string"
},
"packageUri": {
"type": "string",
"defaultValue": "[concat('https://github.com/InRule/AzureAppServices/releases/download/v', parameters('inRuleVersion'),'/InRule.CRM.WebJob.zip')]"
}
},
"variables": {
"appServicePlanName": "[if(empty(parameters('appServicePlanName')), concat(parameters('appServiceName'),'Plan'), parameters('appServicePlanName'))]"
},
"resources": [
{
"condition": "[parameters('createAppServicePlan')]",
"name": "[variables('appServicePlanName')]",
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2016-09-01",
"location": "[resourceGroup().location]",
"properties": {
"name": "[variables('appServicePlanName')]"
},
"sku": {
"name": "[parameters('appServicePlanSkuName')]"
}
},
{
"name": "[parameters('appServiceName')]",
"type": "Microsoft.Web/sites",
"apiVersion": "2016-08-01",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId(parameters('servicePlanResourceGroupName'), 'Microsoft.Web/serverfarms', variables('appServicePlanName'))]"
],
"tags": {
"[concat('hidden-related:', resourceId(parameters('servicePlanResourceGroupName'), 'Microsoft.Web/serverfarms', variables('appServicePlanName')))]": "Resource"
},
"properties": {
"serverFarmId": "[resourceId(parameters('servicePlanResourceGroupName'), 'Microsoft.Web/serverfarms', variables('appServicePlanName'))]",
"siteConfig": {
"AlwaysOn": true,
"use32BitWorkerProcess": false
}
},
"resources": [
{
"name": "MSDeploy",
"type": "extensions",
"apiVersion": "2016-08-01",
"dependsOn": [
"[concat('Microsoft.Web/sites/', parameters('appServiceName'))]"
],
"properties": {
"packageUri": "[parameters('packageURI')]"
}
},
{
"name": "appsettings",
"type": "config",
"apiVersion": "2016-08-01",
"dependsOn": [
"[concat('Microsoft.Web/Sites/', parameters('appServiceName'), '/Extensions/MSDeploy')]",
"[concat('Microsoft.Web/sites/', parameters('appServiceName'))]"
],
"properties": {
"inrule:crm:catalog:label": "LIVE",
"inrule:crm:catalog:user": "[parameters('catalogUser')]",
"inrule:crm:catalog:password": "[parameters('catalogPassword')]",
"inrule:crm:catalog:sso": "false",
"inrule:crm:catalog:uri": "[parameters('catalogUri')]",
"inrule:crm:catalog:ruleAppDirectory": "C:\\RuleApps",
"inrule:crm:catalog:useInRuleCatalog": "true",
"inrule:crm:serviceBus:key": "[listKeys(resourceId('Microsoft.Relay/namespaces/authorizationRules', parameters('relayName'), 'RootManageSharedAccessKey'), providers('Microsoft.Relay', 'namespaces').apiVersions[0]).primaryKey]",
"inrule:crm:serviceBus:namespace": "[parameters('relayName')]",
"inrule:crm:serviceBus:owner": "RootManageSharedAccessKey",
"inrule:crm:serviceBus:path": "ruleexecution",
"inrule:crm:s2s:azureAppId": "[parameters('appId')]",
"inrule:crm:s2s:azureAppSecret": "[parameters('appSecret')]",
"inrule:crm:s2s:crmOrgUrl": "[parameters('orgUrl')]",
"inrule:repository:licensing:licenseFolder": "D:\\home\\site\\wwwroot",
"inrule:logging:level": "Warn",
"inrule:logging:appInsights:instrumentationKey": "[parameters('appInsightsInstrumentationKey')]"
}
},
{
"condition": "[not(equals(parameters('crmConnectionString'), ''))]",
"name": "connectionstrings",
"type": "config",
"apiVersion": "2016-08-01",
"dependsOn": [
"[concat('Microsoft.Web/Sites/', parameters('appServiceName'), '/Extensions/MSDeploy')]",
"[concat('Microsoft.Web/sites/', parameters('appServiceName'))]"
],
"properties": {
"DynamicsCrm": {
"value": "[parameters('crmConnectionString')]",
"type": "Custom"
}
}
}
]
},
{
"name": "[parameters('relayName')]",
"type": "Microsoft.Relay/namespaces",
"apiVersion": "2017-04-01",
"location": "[resourceGroup().location]",
"properties": {}
}
],
"outputs": {
"relayKey": {
"type": "string",
"value": "[listKeys(resourceId('Microsoft.Relay/namespaces/authorizationRules', parameters('relayName'), 'RootManageSharedAccessKey'), providers('Microsoft.Relay', 'namespaces').apiVersions[0]).primaryKey]"
}
}
}
42 changes: 42 additions & 0 deletions Dynamics/InRule.Dynamics.Service.parameters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appServiceName": {
"value": ""
},
"relayName": {
"value": ""
},
"catalogUri": {
"value": "https://{Context}/Service.svc"
},
"catalogUser": {
"value": "admin"
},
"catalogPassword": {
"value": "password"
},
"orgUrl": {
"value": ""
},
"appId": {
"value": ""
},
"appSecret": {
"value": ""
},
"crmConnectionString": {
"value": ""
},
"appServicePlanName": {
"value": ""
},
"inRuleVersion": {
"value": "5.4.3"
},
"appInsightsInstrumentationKey": {
"value": ""
}
}
}
13 changes: 13 additions & 0 deletions Dynamics/InruleCrmAzure.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<version>0.00</version>
<authors>InRule Technology, Inc.</authors>
<id>InRule.Crm.Azure</id>
<title>InRule.Crm.Azure</title>
<description>This nuget package contains the needed files to deploy the arm template with octopus.</description>
</metadata>
<files>
<file src="*.json"/>
</files>
</package>
92 changes: 92 additions & 0 deletions Dynamics/Register-AzureApp.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<#
.SYNOPSIS
Registers an application in Azure AD for authenticating the InRule Integration Framework with Dynamics CRM
.DESCRIPTION
Use this script if you plan on using Server-to-Server authentication with an application user instead of a regular service account for communication from the InRule integration framework to Dynamics CRM.
This script will register an application in Azure AD, and create an authentication key and service principal for access
The app ID and key secret will be output at the end of the script. Please save these values for configuration of the InRule Rule Execution Service later
.PARAMETER Username
Azure AD username for a user with Global Administrator privileges
This is an optional paramter; if not included, interactive login will be used
.PARAMETER Password
Password for the provided username
This is an optional paramter; if not included, interactive login will be used
.PARAMETER TenantId
The Azure AD tenant to create register the app in
This is an optional parameter; if not included, the user's default tenant will be used
.EXAMPLE
.\Register-AzureApp.ps1 -User
.NOTES
This script requires the Azure Active Directory PowerShell module. If it is not yet installed, you can install it by running 'Install-Module AzureAD' at an elevated PowerShell prompt
#>

param(
[string]$Username,
[string]$Password,
[string]$TenantId
)
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12
$erroractionpreference = "Continue"

$appName = "InRuleDynamicsCrmIntegration"
$appURI = "https://InRuleDynamicsCrmIntegration.azurewebsites.net"

if ($Username -and $Password)
{
$securePW = ConvertTo-SecureString -String $Password -AsPlainText -Force
$creds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Username, $securePw

if (!$TenantId)
{
Connect-AzureAD -Credential $creds
}
else
{
Connect-AzureAD -Credential $creds -TenantId $TenantId
}
}
else
{
if (!$TenantId)
{
Connect-AzureAD
}
else
{
Connect-AzureAD -TenantId $TenantId
}
}

if(!($myApp = Get-AzureADApplication -Filter "DisplayName eq '$($appName)'" -ErrorAction SilentlyContinue))
{
$startDate = Get-Date
$endDate = "2099-01-01T13:45:30"

$myApp = New-AzureADApplication -DisplayName $appName -IdentifierUris $appURI

$aadAppKeyPwd = New-AzureADApplicationPasswordCredential -ObjectId $myApp.ObjectId -CustomKeyIdentifier "Primary" -StartDate $startDate -EndDate $endDate

New-AzureADServicePrincipal -AppId $myApp.AppId

$appDetailsOutput = "Application Details for the $appName application:
=========================================================
Application Name: $appName
Application Id: $($myApp.AppId)
Secret Key: $($aadAppKeyPwd.Value)
"
Write-Host
Write-Host $appDetailsOutput
}
else
{
Write-Host
Write-Host -f Yellow Azure AD Application $appName already exists.

$appDetailsOutput = "Application Details for the $appName application:
=========================================================
Application Name: $appName
Application Id: $($myApp.AppId)
"
Write-Host
Write-Host $appDetailsOutput
}
Loading

0 comments on commit 1250db7

Please sign in to comment.