Skip to content

Commit 75c3537

Browse files
Uploaded notebook files with my updates
1 parent 1355673 commit 75c3537

2 files changed

Lines changed: 61 additions & 35 deletions

File tree

samples/manage/sql-assessment-api/notebooks/SQLAssessmentAPIQuickStartNotebook.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"cell_type": "markdown",
2929
"source": [
3030
"### 1. Setup\r\n",
31-
"You need to install PowerShell SqlServer module using the following command. It is a good practice to run Import-Module at the beginning of your session as well. Get-Module will show you the version you have installed. The minimum version you want is 21.1.18206 (SQL Assessment API GA)."
31+
"You need to install PowerShell SqlServer module using the following command. It is a good practice to run Import-Module at the beginning of your session as well. Get-Module will show you the version you have installed. The minimum version you want is 21.1.18206 — it is the version of SqlServer module containing SQL Assessment API GA."
3232
],
3333
"metadata": {
3434
"azdata_cell_guid": "2060c61e-6488-4b54-8aa8-8604a6159c0c"

samples/manage/sql-assessment-api/notebooks/SQLAssessmentAPITutorialNotebook.ipynb

Lines changed: 60 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@
4242
"\r\n",
4343
"There are two cmdlets: \r\n",
4444
"\r\n",
45-
"1. **Get-SqlAssessmentItem** shows a list of available rules for a given object (instance, database). Every rule has a target that describes what kind of SQL objects this rule applies to: SQL Server version, SQL Server platform, SQL Server engine edition. So by the availability of a rule, we mean that when you run Get-SqlAssessmentItem or Invoke-SqlAssessment, the API first verifies what rules aplly for the given object. \r\n",
45+
"1. **Get-SqlAssessmentItem** shows a list of available rules for a given object (5 kinds of objects is currently supported as input: Server, RegisteredServer, Database, AvailabilityGroup, Filegroup; the default ruleset contains rules for Server/RegisteredServer and Database only). Every rule has a target that describes what kind of SQL objects this rule applies to: Object Type, Object Name, SQL Server version, SQL Server platform, SQL Server engine edition. So by the availability of a rule, we mean that when you run Get-SqlAssessmentItem or Invoke-SqlAssessment, the API first verifies what rules apply for the given object. \r\n",
4646
"\r\n",
47-
"2. **Invoke-SqlAssessment** performs an assessment of a passed object and provides the results. "
47+
"2. **Invoke-SqlAssessment** performs an assessment of a passed object and provides the results. It's worthwhile to mention that assessment is invoked for a passed object only, so if you want to assess a SQL Server instance and all its databases, run the cmdlet with the instance object as input and then run it with the databases as input. We'll show you different ways of doing this below."
4848
],
4949
"metadata": {
5050
"azdata_cell_guid": "424b5be9-3f95-4fa0-b630-b5507a0e5db2"
@@ -54,7 +54,7 @@
5454
"cell_type": "markdown",
5555
"source": [
5656
"### 1. Setup\r\n",
57-
"You need to install PowerShell SqlServer module using the following command. It is a good practice to run Import-Module at the beginning of your session as well. Get-Module will show you the version you have installed. The minimum version you want is 21.1.18206 (SQL Assessment API GA)."
57+
"You need to install PowerShell SqlServer module using the following command. It is a good practice to run Import-Module at the beginning of your session as well. Get-Module will show you the version you have installed. The minimum version you want is 21.1.18206 — it is the version of SqlServer module containing SQL Assessment API GA. You can [read more](https://docs.microsoft.com/sql/powershell/download-sql-server-ps-module) about installing and updating the SqlServer module on docs."
5858
],
5959
"metadata": {
6060
"azdata_cell_guid": "9575ad0b-daca-48ac-84f1-59431afd1387"
@@ -72,14 +72,15 @@
7272
"azdata_cell_guid": "bf6a34ad-a006-4b24-858d-5d08b760b231"
7373
},
7474
"outputs": [],
75-
"execution_count": 4
75+
"execution_count": 2
7676
},
7777
{
7878
"cell_type": "markdown",
7979
"source": [
80-
"### 2. Invoke an assessment (SQL Server instance)\r\n",
81-
"There are various ways to run the assessment cmdlet. The following statements give recommendations for local default instance. Pick whatever style works for your script.\r\n",
82-
""
80+
"### 2. Invoke an assessment for SQL Server instance\r\n",
81+
"There are various ways to run the assessment cmdlet. The following statements give recommendations for a local default instance. Pick whatever style works for your script.\r\n",
82+
"\r\n",
83+
"Server and RegisteredServer objects are interchangeable, so you can pass any to the SQL Assessment cmdlets to assess a SQL Server instance."
8384
],
8485
"metadata": {
8586
"azdata_cell_guid": "a34fa4e1-bf4e-44c9-9274-3fca29a6c535"
@@ -160,10 +161,22 @@
160161
"outputs": [],
161162
"execution_count": 16
162163
},
164+
{
165+
"cell_type": "code",
166+
"source": [
167+
"# Option 7 - passing registered servers to the cmdlet\r\n",
168+
"Get-ChildItem 'SQLSERVER:\\SQLRegistration\\Database Engine Server Group' | WHERE { $_.Mode -ne 'D'} | Invoke-SqlAssessment"
169+
],
170+
"metadata": {
171+
"azdata_cell_guid": "dc8b69d6-6d20-4115-a68a-f6abd39d6c4a"
172+
},
173+
"outputs": [],
174+
"execution_count": 0
175+
},
163176
{
164177
"cell_type": "markdown",
165178
"source": [
166-
"### 3. Invoke an assessment (SQL Server database)\r\n",
179+
"### 3. Invoke an assessment for SQL Server database\r\n",
167180
"You need to run Invoke-SqlAssessment against a database object to get database specific recommendations. Again, there are various ways of accomplishing this. Below are some examples."
168181
],
169182
"metadata": {
@@ -212,10 +225,11 @@
212225
"cell_type": "code",
213226
"source": [
214227
"# Get recommendations for all databases on local instance:\r\n",
215-
"Get-SqlDatabase -ServerInstance 'localhost' | Invoke-SqlAssessment -Verbose"
228+
"Get-SqlDatabase -ServerInstance 'localhost' | Invoke-SqlAssessment"
216229
],
217230
"metadata": {
218-
"azdata_cell_guid": "b374c2ec-8d2e-4c35-a48a-c427dec9c21c"
231+
"azdata_cell_guid": "b374c2ec-8d2e-4c35-a48a-c427dec9c21c",
232+
"tags": []
219233
},
220234
"outputs": [],
221235
"execution_count": 26
@@ -236,7 +250,7 @@
236250
"source": [
237251
"# Get all rules available for an object:\r\n",
238252
"$serverInstance = Get-SqlInstance -ServerInstance 'localhost'\r\n",
239-
"Get-SqlAssessmentItem $serverInstance | Select ID, Description | Format-Table"
253+
"Get-SqlAssessmentItem $serverInstance | Select Id, Description"
240254
],
241255
"metadata": {
242256
"azdata_cell_guid": "56b4a035-658b-4bc4-8870-90823b8c2549"
@@ -261,9 +275,9 @@
261275
"cell_type": "markdown",
262276
"source": [
263277
"### 5. Run a specific rule\r\n",
264-
"If you want to check a particular rule (maybe after you fixed it), you can run it by its name. You can also specify several rules in the Check parameter, just delimit them by commas.\r\n",
278+
"If you want to check a particular rule (maybe after you fixed it), you can run it by its name. You can also specify several rules in the -Check parameter, just delimit them by commas.\r\n",
265279
"\r\n",
266-
"Every rule in the default ruleset has tags to group them into logical sets. In the example below, we look for backup related issues only. Backup value used for the Check parameter is a tag. You can use both rule names and tags at the same time in a comma delimited list. "
280+
"Every rule in the default ruleset has tags to group them into logical sets. In the example below, we look for backup related issues only. Backup value used for the -Check parameter is a tag. You can use both rule names and tags at the same time in a comma delimited list. "
267281
],
268282
"metadata": {
269283
"azdata_cell_guid": "0267d880-c35e-4fbf-90db-dd9120194da9"
@@ -323,7 +337,8 @@
323337
"## Customization\r\n",
324338
"In this section you will learn how to customize existing rules and create new ones.\r\n",
325339
"\r\n",
326-
"You need to grab the json files in the Customization Sample JSON folder and place them in an accessible path. You need to edit the scripts below to point at the right path and server instance for your environment."
340+
"As a prerequisite, make sure to grab the JSON files in the CustomizationSamples folder and place them in an accessible path and then edit the first script below to point at the right path and server instance for your environment. We encourage you to look into every JSON sample so you can understand better the making of customizations for SQL Assessment.\r\n",
341+
""
327342
],
328343
"metadata": {
329344
"azdata_cell_guid": "3cfbe027-21f0-40be-b6f0-b871360aff5d"
@@ -341,16 +356,28 @@
341356
{
342357
"cell_type": "code",
343358
"source": [
344-
"# Setup two parameters that are used in all the customization examples below\r\n",
345-
"# $binariesPath=\"<replace this with the path to customization sample json files>\"\r\n",
346-
"$binariesPath=\"C:\\Users\\ebrue\\OneDrive - Microsoft\\Monitoring\\API\\Custimization Sample JSON\"\r\n",
347-
"$serverInstance = Get-SqlInstance -ServerInstance 'localhost'"
359+
"#Setup two parameters that are used in all the customization examples below\r\n",
360+
"#$binariesPath='<replace this with the path to customization json files, e.g. \"C:\\SQLAsmnt\\CustomizationSamples\">' \r\n",
361+
"$binariesPath='C:\\SQLAsmnt\\CustomizationSamples'\r\n",
362+
"######REMOVELINEBELOW\r\n",
363+
"$binariesPath='D:\\Temp\\dem\\Wed Version\\notebooks\\CustomizationSamples'\r\n",
364+
"$binariesPath\r\n",
365+
"\r\n",
366+
"#$serverInstance = Get-SqlInstance -ServerInstance 'localhost'\r\n",
367+
"######REMOVELINEBELOW\r\n",
368+
"$serverInstance = Get-SqlInstance -ServerInstance '.\\sql2017express'\r\n",
369+
"$serverInstance\r\n",
370+
"\r\n",
371+
"$sqlDbMaster = $serverInstance | Get-SqlDatabase -Name master\r\n",
372+
"$sqlDbMaster\r\n",
373+
""
348374
],
349375
"metadata": {
350-
"azdata_cell_guid": "5df878e7-8204-45c8-8bb2-4861131f3588"
376+
"azdata_cell_guid": "5df878e7-8204-45c8-8bb2-4861131f3588",
377+
"tags": []
351378
},
352379
"outputs": [],
353-
"execution_count": 40
380+
"execution_count": 37
354381
},
355382
{
356383
"cell_type": "code",
@@ -364,7 +391,7 @@
364391
"azdata_cell_guid": "7a2a90f0-8341-4cd8-81a3-1fdedbd1adb6"
365392
},
366393
"outputs": [],
367-
"execution_count": 74
394+
"execution_count": 7
368395
},
369396
{
370397
"cell_type": "code",
@@ -374,24 +401,25 @@
374401
"Get-SqlAssessmentItem $serverInstance -Configuration $(join-path $binariesPath \"DisableAllTF.json\")"
375402
],
376403
"metadata": {
377-
"azdata_cell_guid": "35ee6731-70dd-42b9-b041-f3b09ac02a4d"
404+
"azdata_cell_guid": "35ee6731-70dd-42b9-b041-f3b09ac02a4d",
405+
"tags": []
378406
},
379407
"outputs": [],
380-
"execution_count": 76
408+
"execution_count": 9
381409
},
382410
{
383411
"cell_type": "code",
384412
"source": [
385413
"# Combine configurations\r\n",
386-
"# This example disables all trace flag rules except for performance related ones using tags. \r\n",
387-
"# The order of json files is important. First we disable all TF rules, then enable performance rules which re-enables performance related TF rules.\r\n",
414+
"# This example disables all trace flag rules except for performance-related ones using tags. \r\n",
415+
"# The order of json files is important. First we disable all TF rules, then enable performance rules which re-enables performance-related TF rules.\r\n",
388416
"Get-SqlAssessmentItem $serverInstance -Configuration $(join-path $binariesPath \"DisableAllTF.json\"), $(join-path $binariesPath \"EnablePerformance.json\")"
389417
],
390418
"metadata": {
391419
"azdata_cell_guid": "4f79d729-4a3b-47a6-8cb3-d4a5b0c2db05"
392420
},
393421
"outputs": [],
394-
"execution_count": 80
422+
"execution_count": 11
395423
},
396424
{
397425
"cell_type": "markdown",
@@ -413,31 +441,29 @@
413441
{
414442
"cell_type": "code",
415443
"source": [
416-
"# Create new rule with TSQL probe\r\n",
444+
"# Create a new rule with TSQL probe\r\n",
417445
"# This rule applies to databases and uses a TSQL statement to get the data for the rule. \r\n",
418-
"$database = Get-SqlDatabase -ServerInstance 'localhost' -Name master\r\n",
419-
"Invoke-SqlAssessment $database -configuration $(join-path $binariesPath \"CustomRuleTSQLProbe.json\")"
446+
"Invoke-SqlAssessment $sqlDbMaster -configuration $(join-path $binariesPath \"CustomRuleTSQLProbe.json\")"
420447
],
421448
"metadata": {
422449
"azdata_cell_guid": "1df3379f-e5fe-47ea-a43e-920265f3d0e2",
423450
"tags": []
424451
},
425452
"outputs": [],
426-
"execution_count": 66
453+
"execution_count": 45
427454
},
428455
{
429456
"cell_type": "code",
430457
"source": [
431458
"# Override threshold parameter\r\n",
432459
"# CustomRuleThresholdChange.json defines a new threshold value for DBSpaceAvailable rule created above\r\n",
433-
"$database = Get-SqlDatabase -ServerInstance 'localhost' -Name master\r\n",
434-
"Invoke-SqlAssessment $database -configuration $(join-path $binariesPath \"CustomRuleTSQLProbe.json\"),$(join-path $binariesPath \"CustomRuleThresholdChange.json\")"
460+
"Invoke-SqlAssessment $sqlDbMaster -configuration $(join-path $binariesPath \"CustomRuleTSQLProbe.json\"),$(join-path $binariesPath \"CustomRuleThresholdChange.json\")"
435461
],
436462
"metadata": {
437463
"azdata_cell_guid": "953cd87b-4311-4553-9170-e219c231642a"
438464
},
439465
"outputs": [],
440-
"execution_count": 68
466+
"execution_count": 106
441467
},
442468
{
443469
"cell_type": "markdown",
@@ -459,7 +485,7 @@
459485
"azdata_cell_guid": "1c7ef29f-3047-4718-923f-bad632bfdd96"
460486
},
461487
"outputs": [],
462-
"execution_count": 70
488+
"execution_count": 116
463489
},
464490
{
465491
"cell_type": "markdown",

0 commit comments

Comments
 (0)