Skip to content

Commit

Permalink
fix: Adding diagnostics to various ingredients (#159)
Browse files Browse the repository at this point in the history
* Adding diagnostics to various ingredients

* Merging
  • Loading branch information
jchappell003 authored May 21, 2020
1 parent aa792e5 commit 1d6b16a
Show file tree
Hide file tree
Showing 19 changed files with 683 additions and 61 deletions.
79 changes: 74 additions & 5 deletions ingredient/ingredient-databricks/src/arm.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,56 @@
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string"
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]"
},
"workspaceName": {
"type": "string"
},
"tier": {
"defaultValue": "premium",
"type": "string"
},
"diagnosticsEnabled": {
"type": "string",
"defaultValue": "yes",
"metadata": {
"description": "Specifies whether to configure diagnostic settings to expose logs and metrics for consumption."
}
},
"diagnosticsSettingName": {
"type": "string",
"defaultValue": "diagToEHN",
"metadata": {
"description": "Diagnostic setting name. Most by unique for the resource."
}
},
"diagnosticsEventHubResourceGroup": {
"type": "string",
"defaultValue": "",
"metadata": {
"description": "The resource group of the Event Hub Namespace where diagnostics are sent."
}
},
"diagnosticsEventHubNamespace": {
"type": "string",
"defaultValue": "",
"metadata": {
"description": "The Event Hub Namespace where diagnostics are sent."
}
},
"diagnosticsEventHubAuthorizationRule": {
"type": "string",
"defaultValue": "RootManageSharedAccessKey",
"metadata": {
"description": "The authorization rule to use for transmitting diagnostics."
}
}
},
"resources": [
{
"type": "Microsoft.Databricks/workspaces",
"apiVersion": "2018-04-01",
"location": "[parameters('location')]",
"name": "[parameters('workspaceName')]",
Expand All @@ -24,12 +61,44 @@
"comments": "Please do not use an existing resource group for ManagedResourceGroupId.",
"properties": {
"ManagedResourceGroupId": "[variables('managedResourceGroupId')]"
},
"type": "Microsoft.Databricks/workspaces"
},
"resources": [
{
"condition": "[equals(parameters('diagnosticsEnabled'), 'yes')]",
"type": "providers/diagnosticSettings",
"name": "[concat('Microsoft.Insights/', parameters('diagnosticsSettingName'))]",
"dependsOn": [
"[parameters('workspaceName')]"
],
"apiVersion": "2017-05-01-preview",
"properties": {
"name": "[parameters('diagnosticsSettingName')]",
"eventHubAuthorizationRuleId": "[resourceId(parameters('diagnosticsEventHubResourceGroup'),'Microsoft.EventHub/namespaces/authorizationRules', parameters('diagnosticsEventHubNamespace'), parameters('diagnosticsEventHubAuthorizationRule'))]",
"logs": [
{
"category": "workspace",
"enabled": true,
"retentionPolicy": {
"days": 0,
"enabled": false
}
},
{
"category": "jobs",
"enabled": true,
"retentionPolicy": {
"days": 0,
"enabled": false
}
}
]
}
}
]
}
],
"variables": {
"managedResourceGroupId": "[concat(subscription().id, '/resourceGroups/', variables('managedResourceGroupName'))]",
"managedResourceGroupName": "[concat('databricks-rg-', parameters('workspaceName'), '-', uniqueString(parameters('workspaceName'), resourceGroup().id))]"
"managedResourceGroupName": "[concat(parameters('location'), '_', 'databricks')]"
}
}
2 changes: 1 addition & 1 deletion ingredient/ingredient-databricks/src/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export class DataBricksUtils extends BaseUtility {

public create_resource_name(): string {
let util = IngredientManager.getIngredientFunction("coreutils", this.context);
const name = util.create_resource_name("sbn", null, false);
const name = util.create_resource_name("dbrcks", null, true);
return name;
}

Expand Down
23 changes: 16 additions & 7 deletions ingredient/ingredient-databricks/src/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
import { BaseIngredient, IngredientManager } from "@azbake/core"
import { BaseIngredient, IngredientManager,IIngredient,DeploymentContext } from "@azbake/core"
import { ARMHelper } from "@azbake/arm-helper"
import ARMTemplate from "./arm.json"

export class DataBricks extends BaseIngredient {

constructor(name: string, ingredient: IIngredient, ctx: DeploymentContext) {
super(name, ingredient, ctx);
this._helper = new ARMHelper(this._ctx);
}

_helper: ARMHelper;

public async Execute(): Promise<void> {
try {
let util = IngredientManager.getIngredientFunction("coreutils", this._ctx)
this._logger.log('Logical SQL Server Plugin Logging: ' + this._ingredient.properties.source)

const helper = new ARMHelper(this._ctx);

let params = await helper.BakeParamsToARMParamsAsync(this._name, this._ingredient.properties.parameters)

this._logger.log('DataBricks Logging: ' + this._ctx.Ingredient.properties.source)

await helper.DeployTemplate(this._name, ARMTemplate, params, await util.resource_group())
let params = await this._helper.BakeParamsToARMParamsAsync(this._name, this._ctx.Ingredient.properties.parameters)

params = await this._helper.ConfigureDiagnostics(params);

await this._helper.DeployTemplate(this._name, ARMTemplate, params, await util.resource_group())

} catch(error){
this._logger.error('deployment failed: ' + error)
throw error
Expand Down
92 changes: 87 additions & 5 deletions ingredient/ingredient-datafactoryv2/src/arm.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,49 @@
},
"location": {
"type": "string",
"defaultValue": "East US"
"defaultValue": "[resourceGroup().location]"
},
"apiVersion": {
"type": "string",
"defaultValue": "2018-06-01"
},
"diagnosticsEnabled": {
"type": "string",
"defaultValue": "yes",
"metadata": {
"description": "Specifies whether to configure diagnostic settings to expose logs and metrics for consumption."
}
},
"diagnosticsSettingName": {
"type": "string",
"defaultValue": "diagToEHN",
"metadata": {
"description": "Diagnostic setting name. Most by unique for the resource."
}
},
"diagnosticsEventHubResourceGroup": {
"type": "string",
"defaultValue": "",
"metadata": {
"description": "The resource group of the Event Hub Namespace where diagnostics are sent."
}
},
"diagnosticsEventHubNamespace": {
"type": "string",
"defaultValue": "",
"metadata": {
"description": "The Event Hub Namespace where diagnostics are sent."
}
},
"diagnosticsEventHubAuthorizationRule": {
"type": "string",
"defaultValue": "RootManageSharedAccessKey",
"metadata": {
"description": "The authorization rule to use for transmitting diagnostics."
}
}

},
"variables": {
"location": "[concat(uniqueString(subscription().subscriptionId), 'storage')]"
},
"resources": [
{
"apiVersion": "[parameters('apiVersion')]",
Expand All @@ -28,7 +60,57 @@
"identity": {
"type": "SystemAssigned"
},
"properties": {}
"resources": [
{
"condition": "[equals(parameters('diagnosticsEnabled'), 'yes')]",
"type": "providers/diagnosticSettings",
"name": "[concat('Microsoft.Insights/', parameters('diagnosticsSettingName'))]",
"dependsOn": [
"[parameters('name')]"
],
"apiVersion": "2017-05-01-preview",
"properties": {
"name": "[parameters('diagnosticsSettingName')]",
"eventHubAuthorizationRuleId": "[resourceId(parameters('diagnosticsEventHubResourceGroup'),'Microsoft.EventHub/namespaces/authorizationRules', parameters('diagnosticsEventHubNamespace'), parameters('diagnosticsEventHubAuthorizationRule'))]",
"logs": [
{
"category": "ActivityRuns",
"enabled": true,
"retentionPolicy": {
"days": 0,
"enabled": false
}
},
{
"category": "PipelineRuns",
"enabled": true,
"retentionPolicy": {
"days": 0,
"enabled": false
}
},
{
"category": "TriggerRuns",
"enabled": true,
"retentionPolicy": {
"days": 0,
"enabled": false
}
}
],"metrics": [
{
"timeGrain": "PT1M",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
}
]

}
}
]
}
]
}
2 changes: 1 addition & 1 deletion ingredient/ingredient-datafactoryv2/src/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export class DataFactoryV2Utils extends BaseUtility {

public create_resource_name(): string {
let util = IngredientManager.getIngredientFunction("coreutils", this.context);
const name = util.create_resource_name("sbn", null, false);
const name = util.create_resource_name("df", null, true);
return name;
}

Expand Down
19 changes: 14 additions & 5 deletions ingredient/ingredient-datafactoryv2/src/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
import { BaseIngredient, IngredientManager } from "@azbake/core"
import { BaseIngredient, IngredientManager,IIngredient,DeploymentContext } from "@azbake/core"
import { ARMHelper } from "@azbake/arm-helper"
import ARMTemplate from "./arm.json"

export class DataFactoryV2 extends BaseIngredient {

constructor(name: string, ingredient: IIngredient, ctx: DeploymentContext) {
super(name, ingredient, ctx);
this._helper = new ARMHelper(this._ctx);
}

_helper: ARMHelper;

public async Execute(): Promise<void> {
try {
let util = IngredientManager.getIngredientFunction("coreutils", this._ctx)
this._logger.log('Logical SQL Server Plugin Logging: ' + this._ingredient.properties.source)

const helper = new ARMHelper(this._ctx);
this._logger.log('Data Factory Plugin Logging: ' + this._ctx.Ingredient.properties.source)

let params = await this._helper.BakeParamsToARMParamsAsync(this._name, this._ctx.Ingredient.properties.parameters)

let params = await helper.BakeParamsToARMParamsAsync(this._name, this._ingredient.properties.parameters)
params = await this._helper.ConfigureDiagnostics(params);

await helper.DeployTemplate(this._name, ARMTemplate, params, await util.resource_group())
await this._helper.DeployTemplate(this._name, ARMTemplate, params, await util.resource_group())

} catch(error){
this._logger.error('deployment failed: ' + error)
throw error
Expand Down
Loading

0 comments on commit 1d6b16a

Please sign in to comment.