%3CLINGO-SUB%20id%3D%22lingo-sub-1600908%22%20slang%3D%22en-US%22%3ELab%3A%20If%20I%20want%20to%20create%20schedule%20Job%20for%20a%20user%20restore%20point%20on%20SQL%20DW%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1600908%22%20slang%3D%22en-US%22%3E%3CP%3EA%20few%20days%20ago%20I%20was%20discussing%20with%20a%20customer%20about%20backup%20and%20restore%20on%20the%20SQL%20DW%20so%20I%20made%20this%20lab%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-synapse-analytics%2Flab-how-to-restore-a-deleted-database-on-azure-sql-dw%2Fba-p%2F1589360%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3Ehttps%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-synapse-analytics%2Flab-how-to-restore-a-deleted-database-on-azure-sql-dw%2Fba-p%2F1589360%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAfter%20some%20discussion%2C%20another%20doubt%20was%20raised%20about%20how%20to%20schedule%20a%20user%20restore%20point.%20Remember%26nbsp%3B%3CSPAN%3ESQL%20DW%20will%20create%2042%20restore%20points%20and%20the%20user%20can%20additionally%20create%20more%2042%20restore%20points.%20Basically%20it%20is%20a%20point%20in%20time%20restore.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBetween%20some%20possibilities%2C%20one%20of%20them%20is%20to%20use%20the%20run%20book%20to%20schedule%20a%20power%20shell%20restore%20point.%3C%2FP%3E%0A%3CP%3EPublic%20doc%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fautomation%2Fstart-runbooks%23%3A~%3Atext%3D%2520Start%2520a%2520runbook%2520with%2520the%2520Azure%2520portal%2Cthe%2520status%2520of%2520the%2520runbook%2520job.%2520More%2520%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fautomation%2Fstart-runbooks%23%3A~%3Atext%3D%2520Start%2520a%2520runbook%2520with%2520the%2520Azure%2520portal%2Cthe%2520status%2520of%2520the%2520runbook%2520job.%2520More%2520%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHere%20it%20goes...Step%20by%20Step%3A%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELet's%20start%20with%20the%20Run%20Book.%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3ECreate%20an%20automation%20account%20by%20searching%20on%20the%20azure%20portal%3C%2FLI%3E%0A%3CLI%3EAdd%20a%20new%20account%20-%20Fig%201%3A%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CDIV%20id%3D%22tinyMceEditorLiliam_Leme_0%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22automation_account_1.png%22%20style%3D%22width%3A%20646px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F213427i9533A321779747FC%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22automation_account_1.png%22%20alt%3D%22automation_account_1.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%20%26nbsp%3BFig%201%20New%20Account%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3ERunbooks%20-%26gt%3B%20Create%20a%20runbook%20-%20Fig%202%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Create_runbook.png%22%20style%3D%22width%3A%20761px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F213453iFC5DCA933ED45633%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22Create_runbook.png%22%20alt%3D%22Create_runbook.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorLiliam_Leme_1%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3EFig%202%20Create%20a%20Run%20book%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E3.%20Our%20runbook%20will%20use%20power%20shell%20code%20as%20this%20is%20pretty%20much%20the%20example%20available%20on%20the%20public%20doc.%20Fig%203%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorLiliam_Leme_2%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22powershell.png%22%20style%3D%22width%3A%20333px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F213437iE2938997AC3DE164%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22powershell.png%22%20alt%3D%22powershell.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EFig%203%20Power%20Shell%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E4.%20Here%20is%20the%20power%20shell%20script%20for%20a%20customer%20restore%20point%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsynapse-analytics%2Fsql-data-warehouse%2Fsql-data-warehouse-restore-points%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsynapse-analytics%2Fsql-data-warehouse%2Fsql-data-warehouse-restore-points%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%24SubscriptionName%3D%22%3CYOURSUBSCRIPTIONNAME%3E%22%0A%0A%24ResourceGroupName%3D%22%3CYOURRESOURCEGROUPNAME%3E%22%0A%0A%24ServerName%3D%22%3CYOURSERVERNAMEWITHOUTURLSUFFIXSEENOTE%3E%22%26nbsp%3B%20%23%20Without%20database.windows.net%0A%0A%24DatabaseName%3D%22%3CYOURDATABASENAME%3E%22%0A%0A%24Label%20%3D%20%22%3CYOURRESTOREPOINTLABEL%3E%22%0A%0A%0A%0AConnect-AzAccount%0A%0AGet-AzSubscription%0A%0ASelect-AzSubscription%20-SubscriptionName%20%24SubscriptionName%0A%0A%0A%0A%23%20Create%20a%20restore%20point%20of%20the%20original%20database%0A%0ANew-AzSqlDatabaseRestorePoint%20-ResourceGroupName%20%24ResourceGroupName%20-ServerName%20%24ServerName%20-DatabaseName%20%24DatabaseName%20-RestorePointLabel%20%24Label%0A%0A%3C%2FYOURRESTOREPOINTLABEL%3E%3C%2FYOURDATABASENAME%3E%3C%2FYOURSERVERNAMEWITHOUTURLSUFFIXSEENOTE%3E%3C%2FYOURRESOURCEGROUPNAME%3E%3C%2FYOURSUBSCRIPTIONNAME%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E5.%20Once%20you%20fill%20the%20gaps%2C%20open%20power%20shell%20and%20test%20the%20script%3C%2FP%3E%0A%3CP%3E6.%20You%20can%20check%20the%20script's%20result%20on%20the%20SSMS%20by%20running%20the%20following%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3Eselect%20*%20from%20sys.pdw_loader_backup_runs%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20confirm%20it%20worked%20by%20checking%20the%20label%20that%20you%20defined%20for%20the%20restore%20point%20on%20the%20power%20shell%20script.%20My%20label%20was%20portal_test%20-%20Fig%204%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22label_powershell.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F213454iDE8820D74711EB19%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22label_powershell.png%22%20alt%3D%22label_powershell.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorLiliam_Leme_3%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3EFig%204%26nbsp%3B%20check%20label%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E6.%20If%20everything%20is%20working%20as%20it%20should.%20Proceed%20in%20creating%20the%20Job%2C%20in%20other%20words%2C%20back%20to%20run%20book%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHere%20the%20public%20doc%20for%20runbooks%3A%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fautomation%2Flearn%2Fautomation-tutorial-runbook-graphical%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fautomation%2Flearn%2Fautomation-tutorial-runbook-graphical%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%24SubscriptionName%3D%22Name%20of%20your%20Subscription%22%0A%24ResourceGroupName%3D%22Name%20of%20your%20resource%20group%22%20%0A%24ServerName%3D%22Your%20Server%20Name%20%22%20%20%20%23%20Without%20database.windows.net%0A%24DatabaseName%3D%22Your%20Database%20Name%22%0A%24Label%20%3D%20%22Any%20label%20you%20want%20-%20I%20defined%20as%20test%20as%20I%20do%20not%20have%20imagination%22%0A%0A%20%23%20Ensures%20you%20do%20not%20inherit%20an%20AzContext%20in%20your%20runbook%0A%20Disable-AzContextAutosave%20%E2%80%93Scope%20Process%0A%20%0A%20%24Conn%20%3D%20Get-AutomationConnection%20-Name%20AzureRunAsConnection%0A%20Connect-AzAccount%20-ServicePrincipal%20-Tenant%20%24Conn.TenantID%20-ApplicationId%20%24Conn.ApplicationID%20-CertificateThumbprint%20%24Conn.CertificateThumbprint%0A%20%0A%20New-AzSqlDatabaseRestorePoint%20-ResourceGroupName%20%24ResourceGroupName%20-ServerName%20%24ServerName%20-DatabaseName%20%24DatabaseName%20-RestorePointLabel%20%24Label%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENote%3A%26nbsp%3B%20If%20by%20any%20chance%20when%20you%20tried%20to%20use%20the%20run%20book%20you%20experience%20the%20same%20errors%20as%20follows%20(%20I%20did)%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CEM%3EError%3A%20The%20term%20'Connect-AzAccount'%20is%20not%20recognized%20as%20the%20name%20of%20a%20cmdlet%2C%20function%2C%20script%20file%2C%20or%20operable%20program.%20Check%20the%20spelling%20of%20the%20name%2C%20or%20if%20the%20path%20was%20included%20verify%20that%20the%20path%20is%20correct%20and%20try%20again.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20has%20been%20documented%20on%20the%20troubleshooting%20public%20doc%3A%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fautomation%2Ftroubleshoot%2Frunbooks%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fautomation%2Ftroubleshoot%2Frunbooks%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20script%20to%20update%20the%20cmdlet%20is%20on%20the%20GitHub%20-%20run%20it%20on%20the%20runbook%3A%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fraw.githubusercontent.com%2Fmicrosoft%2FAzureAutomation-Account-Modules-Update%2Fmaster%2FUpdate-AutomationAzureModulesForAccount.ps1%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fraw.githubusercontent.com%2Fmicrosoft%2FAzureAutomation-Account-Modules-Update%2Fmaster%2FUpdate-AutomationAzureModulesForAccount.ps1%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20Needed%20the%20%3CSTRONG%3EAz%3C%2FSTRONG%3E%20Modules.%20Therefore%2C%20I%20created%20a%20runbook%20to%20run%20the%20GitHub%20script.%3C%2FP%3E%0A%3CP%3ENote%3A%26nbsp%3B%3CSTRONG%3E%5Bstring%5D%20%24AzureModuleClass%20%3D%20'Az'%2C%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%5BDiagnostics.CodeAnalysis.SuppressMessageAttribute(%22PSUseApprovedVerbs%22%2C%20%22%22)%5D%0Aparam(%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%5BParameter(Mandatory%20%3D%20%24true)%5D%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%5Bstring%5D%20%24ResourceGroupName%2C%0A%0A%5BParameter(Mandatory%20%3D%20%24true)%5D%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%5Bstring%5D%20%24AutomationAccountName%2C%0A%0A%5Bint%5D%20%24SimultaneousModuleImportJobCount%20%3D%2010%2C%0A%0A%5Bstring%5D%20%24AzureModuleClass%20%3D%20'Az'%2C%0A%0A%5Bstring%5D%20%24AzureEnvironment%20%3D%20'AzureCloud'%2C%0A%0A%5Bbool%5D%20%24Login%20%3D%20%24true%2C%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%5Bstring%5D%20%24ModuleVersionOverrides%20%3D%20%24null%2C%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%5Bstring%5D%20%24PsGalleryApiUrl%20%3D%20'https%3A%2F%2Fwww.powershellgallery.com%2Fapi%2Fv2'%0A)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorLiliam_Leme_4%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3EThis%20one%20was%20importing%20the%20AzureRM%2C%20but%20I%20ran%20a%20second%20time%20to%20import%20the%20Az%20as%20well.%20Fig%205%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22update_powershell.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F213435iC16A0C0E1E0C0FEC%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22update_powershell.png%22%20alt%3D%22update_powershell.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EFig%205%20Update%20the%20modules%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20also%20can%20check%20the%20modules%20available%20on%20the%20portal.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAutomation%20accounts-%26gt%3Bname%20of%20your%20account-%26gt%3BShared%20Resources%20-%26gt%3Bmodules%20-%20Fig%206%3A%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorLiliam_Leme_5%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22automation_account_modules.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F213432iA938DF571F7BBE50%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22automation_account_modules.png%22%20alt%3D%22automation_account_modules.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EFig%206%20Check%20Modules%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E7.%20The%20next%20step%20would%20be%20linked%20to%20a%20schedule.%20This%20option%20is%20on%20the%20run%20book%20and%20allows%20you%20to%20add%20an%20existing%20schedule%20or%20create%20a%20new%20one.%20Fig%207%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22link_runbookto%20a%20scheduke.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F213455iF1F200981E1A8AE3%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22link_runbookto%20a%20scheduke.png%22%20alt%3D%22link_runbookto%20a%20scheduke.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EFig%207%20Schedule%20link%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThat%20is%20it!%3C%2FP%3E%0A%3CP%3ELiliam%3C%2FP%3E%0A%3CP%3EUK%20Engineer%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1600908%22%20slang%3D%22en-US%22%3E%3CP%3EHow%20to%20schedule%20a%20user-%20restore%20point%20using%20run%20books%20in%20azure%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1600908%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESynapse%20Administration%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

A few days ago I was discussing with a customer about backup and restore on the SQL DW so I made this lab: https://techcommunity.microsoft.com/t5/azure-synapse-analytics/lab-how-to-restore-a-deleted-database...

 

After some discussion, another doubt was raised about how to schedule a user restore point. Remember SQL DW will create 42 restore points and the user can additionally create more 42 restore points. Basically it is a point in time restore.

 

Between some possibilities, one of them is to use the run book to schedule a power shell restore point.

Public doc: https://docs.microsoft.com/en-us/azure/automation/start-runbooks#:~:text=%20Start%20a%20runbook%20wi...

 

Here it goes...Step by Step: 

 

Let's start with the Run Book.

  1. Create an automation account by searching on the azure portal
  2. Add a new account - Fig 1:
 

automation_account_1.png

   Fig 1 New Account

 

  1. Runbooks -> Create a runbook - Fig 2

Create_runbook.png

 

Fig 2 Create a Run book

 

3. Our runbook will use power shell code as this is pretty much the example available on the public doc. Fig 3

 

 

powershell.png

Fig 3 Power Shell

 

4. Here is the power shell script for a customer restore point: https://docs.microsoft.com/en-us/azure/synapse-analytics/sql-data-warehouse/sql-data-warehouse-resto...

 

 

 

$SubscriptionName="<YourSubscriptionName>"

$ResourceGroupName="<YourResourceGroupName>"

$ServerName="<YourServerNameWithoutURLSuffixSeeNote>"  # Without database.windows.net

$DatabaseName="<YourDatabaseName>"

$Label = "<YourRestorePointLabel>"



Connect-AzAccount

Get-AzSubscription

Select-AzSubscription -SubscriptionName $SubscriptionName



# Create a restore point of the original database

New-AzSqlDatabaseRestorePoint -ResourceGroupName $ResourceGroupName -ServerName $ServerName -DatabaseName $DatabaseName -RestorePointLabel $Label

 

 

 

5. Once you fill the gaps, open power shell and test the script

6. You can check the script's result on the SSMS by running the following:

 

 

 

select * from sys.pdw_loader_backup_runs

 

 

 

 

You can confirm it worked by checking the label that you defined for the restore point on the power shell script. My label was portal_test - Fig 4:

label_powershell.png

 

Fig 4  check label

 

6. If everything is working as it should. Proceed in creating the Job, in other words, back to run book:

 

Here the public doc for runbooks:https://docs.microsoft.com/en-us/azure/automation/learn/automation-tutorial-runbook-graphical

 

 

 

$SubscriptionName="Name of your Subscription"
$ResourceGroupName="Name of your resource group" 
$ServerName="Your Server Name "   # Without database.windows.net
$DatabaseName="Your Database Name"
$Label = "Any label you want - I defined as test as I do not have imagination"

	# Ensures you do not inherit an AzContext in your runbook
	Disable-AzContextAutosave –Scope Process
	
	$Conn = Get-AutomationConnection -Name AzureRunAsConnection
	Connect-AzAccount -ServicePrincipal -Tenant $Conn.TenantID -ApplicationId $Conn.ApplicationID -CertificateThumbprint $Conn.CertificateThumbprint
	
	New-AzSqlDatabaseRestorePoint -ResourceGroupName $ResourceGroupName -ServerName $ServerName -DatabaseName $DatabaseName -RestorePointLabel $Label

 

 

 

 

Note:  If by any chance when you tried to use the run book you experience the same errors as follows ( I did):

 

Error: The term 'Connect-AzAccount' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if the path was included verify that the path is correct and try again.

 

This has been documented on the troubleshooting public doc:

https://docs.microsoft.com/en-us/azure/automation/troubleshoot/runbooks

 

The script to update the cmdlet is on the GitHub - run it on the runbook:

https://raw.githubusercontent.com/microsoft/AzureAutomation-Account-Modules-Update/master/Update-Aut...

 

I Needed the Az Modules. Therefore, I created a runbook to run the GitHub script.

Note: [string] $AzureModuleClass = 'Az',

 

 

 

[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseApprovedVerbs", "")]
param(
    [Parameter(Mandatory = $true)]
    [string] $ResourceGroupName,

[Parameter(Mandatory = $true)]
    [string] $AutomationAccountName,

[int] $SimultaneousModuleImportJobCount = 10,

[string] $AzureModuleClass = 'Az',

[string] $AzureEnvironment = 'AzureCloud',

[bool] $Login = $true,
    
    [string] $ModuleVersionOverrides = $null,
    
    [string] $PsGalleryApiUrl = 'https://www.powershellgallery.com/api/v2'
)

 

 

 

 

This one was importing the AzureRM, but I ran a second time to import the Az as well. Fig 5:

update_powershell.png

Fig 5 Update the modules

 

You also can check the modules available on the portal.

 

Automation accounts->name of your account->Shared Resources ->modules - Fig 6:

 

automation_account_modules.png

Fig 6 Check Modules

 

7. The next step would be linked to a schedule. This option is on the run book and allows you to add an existing schedule or create a new one. Fig 7

link_runbookto a scheduke.png

Fig 7 Schedule link

 

That is it!

Liliam

UK Engineer