%3CLINGO-SUB%20id%3D%22lingo-sub-1475173%22%20slang%3D%22en-US%22%3ERe%3A%20Move%20Your%20Azure%20Sentinel%20Logs%20to%20Long-Term%20Storage%20with%20Ease%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1475173%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F676108%22%20target%3D%22_blank%22%3E%40acoggins%3C%2FA%3E%26nbsp%3BThanks%20for%20bringing%20this%20up.%20Is%20this%20error%20message%20tied%20to%20the%20Azure%20Monitor%20action%3F%20It%20appears%20there%20might%20have%20been%20an%20issue%20with%20getting%20the%20subscription%20ID%20into%20the%20parameters%20for%20the%20query.%20If%20you%20go%20back%20to%20the%20designer%20%26gt%3B%20Azure%20Monitor%2C%20make%20sure%20that%20the%20subscription%20name%20is%20listed%20there%20and%20has%20a%20drop%20down%20arrow%20and%20not%20an%20'x'.%20If%20possible%2C%20please%20paste%20a%20screenshot%20of%20the%20issue%20so%20that%20I%20can%20make%20sure%20that%20I%20am%20helping%20you%20with%20the%20right%20thing.%3C%2FP%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%22Matt_Lowe_0-1592507302052.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F199563iD0129C81BE980860%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22Matt_Lowe_0-1592507302052.png%22%20alt%3D%22Matt_Lowe_0-1592507302052.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1475076%22%20slang%3D%22en-US%22%3ERe%3A%20Move%20Your%20Azure%20Sentinel%20Logs%20to%20Long-Term%20Storage%20with%20Ease%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1475076%22%20slang%3D%22en-US%22%3E%3CP%3EDate%20from%20template%20is%20using%20incorrect%20date%20from%20my%20testing.%20It%20should%20be%20-88%20days%2C%20it%20is%20currently%20listed%20as%20-28%20days.%20Will%20be%20updating%20today.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1475182%22%20slang%3D%22en-US%22%3ERe%3A%20Move%20Your%20Azure%20Sentinel%20Logs%20to%20Long-Term%20Storage%20with%20Ease%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1475182%22%20slang%3D%22en-US%22%3E%3CP%3EThey%20do%20have%20an%20X%20and%20not%20a%20dropdown!%20How%20do%20I%20update%20that%3F%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F572591%22%20target%3D%22_blank%22%3E%40Matt_Lowe%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22acoggins_0-1592507508445.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F199564i06F6FFD5B00EE98B%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22acoggins_0-1592507508445.png%22%20alt%3D%22acoggins_0-1592507508445.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1475150%22%20slang%3D%22en-US%22%3ERe%3A%20Move%20Your%20Azure%20Sentinel%20Logs%20to%20Long-Term%20Storage%20with%20Ease%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1475150%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F572591%22%20target%3D%22_blank%22%3E%40Matt_Lowe%3C%2FA%3E%26nbsp%3B!%20Thanks%20so%20much%20for%20posting%20this.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAfter%20deploying%20the%20logic%20app%2C%20I'm%20getting%20a%20bad%20request%20error%20on%20the%20first%20run%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3E%22Message%22%3C%2FSPAN%3E%3CSPAN%3E%3A%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22User%26nbsp%3Binput%26nbsp%3Bis%26nbsp%3Binvalid.%26nbsp%3BPlease%26nbsp%3Bcheck%26nbsp%3Bquery%26nbsp%3Bsyntax%2C%26nbsp%3BChart%26nbsp%3BType%26nbsp%3Bor%26nbsp%3Bother%26nbsp%3Bparameters%26nbsp%3Bdata.%26nbsp%3BResponse%26nbsp%3BStatus%3DHttpJsonResponse%3A%26nbsp%3BResultStatus%3DNotFound%2C%26nbsp%3BResponse%26nbsp%3BContent%3D%7B%5Cr%5Cn%26nbsp%3B%26nbsp%3B%5C%22error%5C%22%3A%26nbsp%3B%7B%5Cr%5Cn%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%5C%22code%5C%22%3A%26nbsp%3B%5C%22SubscriptionNotFound%5C%22%2C%5Cr%5Cn%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%5C%22message%5C%22%3A%26nbsp%3B%5C%22The%26nbsp%3Bsubscription%26nbsp%3B'XXX-XX-SUB1'%26nbsp%3Bcould%26nbsp%3Bnot%26nbsp%3Bbe%26nbsp%3Bfound.%5C%22%5Cr%5Cn%26nbsp%3B%26nbsp%3B%7D%5Cr%5Cn%7D%5Cr%5CnclientRequestId%3A%26nbsp%3B8e129f9c-17a8-4972-ba79-166c1e6fbf49%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1475198%22%20slang%3D%22en-US%22%3ERe%3A%20Move%20Your%20Azure%20Sentinel%20Logs%20to%20Long-Term%20Storage%20with%20Ease%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1475198%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F676108%22%20target%3D%22_blank%22%3E%40acoggins%3C%2FA%3E%20click%20the%20x's%20and%20the%20drop%20down%20option%20will%20appear.%20Choose%20the%20subscription%20that%20you%20were%20trying%20to%20choose%20the%20first%20time%20and%20the%20rest%20of%20the%20items%20should%20be%20fixed.%20If%20not%2C%20click%20on%20the%20x's%20for%20those%20too%20and%20choose%20the%20correct%20options%20that%20you%20were%20trying%20to%20use.%20Let%20me%20know%20if%20that%20helps!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1407153%22%20slang%3D%22en-US%22%3EMove%20Your%20Azure%20Sentinel%20Logs%20to%20Long-Term%20Storage%20with%20Ease%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1407153%22%20slang%3D%22en-US%22%3E%3CP%3EOut%20of%20the%20box%2C%20Azure%20Sentinel%20provides%20%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fen-us%2Fpricing%2Fdetails%2Fazure-sentinel%2F%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E90%20days%20of%20data%20retention%20for%20free%3C%2FA%3E.%20In%20some%20parts%20of%20the%20world%20and%20within%20certain%20industries%2C%20there%20are%20regulations%20that%20organizations%20must%20adhere%20to%20which%20require%20data%20retention%20up%20to%207%20years%20or%20longer.%20The%20current%20challenge%20is%20that%20the%20max%20retention%20for%20Log%20Analytics%20workspaces%20is%202%20years.%20There%20has%20been%20a%20need%20for%20a%20solution%20that%20will%20allow%20for%20more%20time%20and%20cost%20saving%20by%20moving%20logs%20to%20cold%20storage.%20This%20blog%20is%20going%20to%20detail%20how%20logs%20from%20a%20Log%20Analytics%20workspace%20can%20easily%20be%20moved%20into%20long-term%20cold%20storage%20in%20order%20to%20comply%20with%20retention%20standards%20as%20well%20as%20reduce%20costs%20using%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Sentinel%2Ftree%2Fmaster%2FPlaybooks%2FMove-LogAnalytics-to-Storage%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ethis%20Playbook%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EEnd%20Results%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Storage.gif%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F193672iB3E377F26407CB15%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22Storage.gif%22%20alt%3D%22Logs%20are%20put%20into%20Blobs%20within%20folders%20that%20are%20labeled%20by%20data%20type.%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3ELogs%20are%20put%20into%20Blobs%20within%20folders%20that%20are%20labeled%20by%20data%20type.%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EThis%20post%20is%20going%20to%20be%20in-depth%20as%20it%20breaks%20down%20how%20the%20Playbook%20is%20going%20to%20operate.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ETL%3ADR%3C%2FSTRONG%3E%20The%20end%20result%20once%20the%20Playbook%20is%20run%20is%20a%20folder%20system%20with%20Blobs%20within%20a%20storage%20account%20and%20container.%20The%20folders%20are%20labeled%20with%20and%20contain%20the%20data%20types%20that%20have%20been%20chosen%20for%20back%20up.%20Each%20Blob%20in%20the%20folder%20will%20contain%20a%20backup%20of%20logs%20for%20each%20data%20type%20in%20hourly%20blocks.%20Each%20Blob%20can%20be%20queried%20in%20a%20Log%20Analytics%20workspace%20using%20the%20externaldata%20operator%20and%20a%20SAS%20token%20URL%20generated%20for%20the%20Blob.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELink%20for%20the%20Playbook%20if%20needed%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FAzure-Sentinel%2Ftree%2Fmaster%2FPlaybooks%2FMove-LogAnalytics-to-Storage%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FAzure%2FAzure-Sentinel%2Ftree%2Fmaster%2FPlaybooks%2FMove-LogAnalytics-to-Storage%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E*Note%3A%20If%20your%20Blobs%20are%20a%20size%20of%202B%2C%20there%20was%20no%20information%20for%20that%20time%20block%20or%20data%20type.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPre-requisites%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ELog%20Analytics%20Workspace%3C%2FLI%3E%0A%3CLI%3EAzure%20Storage%20Account%20or%20permissions%20to%20create%20a%20new%20one%3C%2FLI%3E%0A%3CLI%3EOne%20storage%20container%20or%20permissions%20to%20create%20one%3C%2FLI%3E%0A%3CLI%3EThe%20Logic%20App%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EFor%20auditing%20and%20investigative%20purposes%2C%20raw%20data%20and%20logs%20may%20need%20to%20be%20stored%20long%20term%20for%20regulatory%20compliance.%20This%20can%20be%20achieved%20through%20a%20Playbook%20that%20queries%20the%20logs%20from%20the%20workspace%20that%20are%20about%20to%20expire%20and%20moves%20them%20to%20a%20storage%20account%20of%20your%20choosing.%20The%20Playbook%20utilizes%20Log%20Analytics%20API%20when%20performing%20the%20query.%20An%20important%20piece%20of%20information%20to%20note%20is%20that%20%3CU%3Ethe%20API%20has%20a%20limitation%20of%20500%2C000%20rows%20of%20data%20per%20request.%20This%20means%20that%20if%20any%20data%20type%20contains%20more%20than%20500%2C000%20rows%20of%20information%2C%20it%20will%20require%20the%20Playbook%20to%20run%20a%20Log%20Analytics%20API%20pull%20more%20than%20once%20to%20get%20the%20data.%3C%2FU%3E%20In%20order%20to%20avoid%20this%20issue%2C%20the%20Playbook%20breaks%20up%20data%20for%20each%20day%20into%20hourly%20blocks%20in%20order%20to%20efficiently%20and%20carefully%20back%20up%20all%20desired%20data.%20Each%20time%20that%20the%20Playbook%20is%20run%2C%20it%20reviews%20each%20data%20type%20within%20your%20workspace%20that%20should%20be%20backed%20up%2C%20goes%20through%20the%20logs%20for%20those%20data%20types%2C%20and%20moves%20the%20logs%20to%20storage%2C%20labeling%20each%20backup%20with%20the%20data%20type%2C%20the%20date%20of%20the%20log%2C%20and%20the%20hour%20for%20the%20time%20block.%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-center%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Matt_Lowe_0-1592184465562.png%22%20style%3D%22width%3A%20414px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F198723i3C9AB137DED2CC6D%2Fimage-dimensions%2F414x428%3Fv%3D1.0%22%20width%3D%22414%22%20height%3D%22428%22%20title%3D%22Matt_Lowe_0-1592184465562.png%22%20alt%3D%22Matt_Lowe_0-1592184465562.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-center%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Matt_Lowe_1-1592184507352.png%22%20style%3D%22width%3A%20412px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F198724iB98512F08B19E853%2Fimage-dimensions%2F412x462%3Fv%3D1.0%22%20width%3D%22412%22%20height%3D%22462%22%20title%3D%22Matt_Lowe_1-1592184507352.png%22%20alt%3D%22Matt_Lowe_1-1592184507352.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20app%20is%20comprised%20of%20many%20steps%20and%20variables%20in%20order%20for%20it%20to%20work.%20The%20pieces%20are%20the%20following%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ERecurrence%20trigger%20-%20Automatically%20run%20the%20app%20daily%20without%20needing%20manual%20input.%3C%2FLI%3E%0A%3CLI%3EhoursCount%20-%20Counter%20variable%20that%20is%20used%20for%20tracking%20which%20hour%20the%20Playbook%20is%20on%20for%20exporting%20data.%20Starts%20at%200%20for%20midnight%20and%20caps%20at%2024.%3C%2FLI%3E%0A%3CLI%3EstartDate%20-%20Oldest%20date%20in%20a%20range%20that%20the%20queries%20will%20be%20using.%20Value%20is%20set%20to%20the%20current%20date%20minus%2089%20days%20(formatDateTime(addDays(utcNow()%2C%20-89)%2C'yyyy-MM-dd')).%20This%20serves%20as%20the%20starting%20point%20for%20the%20time%20range%20to%20pull%20data%20from.%3C%2FLI%3E%0A%3CLI%3EendDate%20-%20Similar%20to%20startDate%2C%20this%20variable%20serves%20to%20be%20the%20tail%20end%20of%20the%20time%20range.%20This%20value%20is%20set%20to%20the%20current%20date%20minus%2088%20days%20(formatDateTime(addDays(utcNow()%2C%20-88)%2C'yyyy-MM-dd')).%20The%20time%20range%20between%20startDate%20and%20endDate%20are%20now%2089%20days%20ago%20and%2088%20days%20ago.%20The%20purpose%20for%20this%20is%20to%20move%20logs%20to%20storage%2024%20hours%20before%20they%20are%20deleted%20from%20the%20workspace.%3C%2FLI%3E%0A%3CLI%3EexcludedDataType%20-%20This%20variable%20is%20used%20to%20hold%20a%20list%20of%20data%20types%20that%20should%20not%20be%20backed%20up%20when%20running%20the%20Playbook.%20The%20list%20of%20options%20will%20be%20used%20in%20the%20query%20that%20checks%20to%20see%20which%20data%20types%20should%20be%20backed%20up.%20It%20is%20recommended%20that%20the%20data%20types%20chosen%20are%20logs%20that%20are%20noisy%20or%20are%20not%20important.%3C%2FLI%3E%0A%3CLI%3EQuery%20%231%20-%26nbsp%3BThis%20query%20sets%20which%20log%20types%20should%20not%20be%20included%20based%20on%20the%20excluded%20variable.%20The%20query%20then%20checks%20the%20usage%20details%20to%20see%20which%20data%20is%20present%20in%20the%20workspace%20between%2089%20days%20ago%20and%2088%20days%20ago.%3C%2FLI%3E%0A%3CLI%3ECompose%20-%20Composes%20the%20data%20for%20parsing%20for%20future%20use%20in%20the%20app.%3C%2FLI%3E%0A%3CLI%3EParse%20JSON%20-%20Parses%20the%20message%20from%20the%20query%20so%20that%20each%20item%20from%20the%20query%20results%20can%20be%20referenced%20later%20in%20the%20Playbook.%20The%20sample%20JSON%20for%20the%20step%20is%20provided%20in%20the%20template.%3C%2FLI%3E%0A%3CLI%3EAll%20of%20the%20details%20are%20then%20passed%20into%20a%20ForEach%20loop%20that%20then%20goes%20into%20an%20until%20loop%20that%20checks%20if%20hoursCount%20is%2024.%20Each%20time%20that%20the%20logs%20are%20exported%20for%20a%20data%20type%2C%20it%20will%20increment%20the%20counter%20by%201%20until%20it%20hits%2024%2C%20then%20moves%20onto%20the%20next%20data%20type.%3C%2FLI%3E%0A%3CLI%3EQuery%20%232%20-%20This%20query%20takes%20in%20the%20value%20of%20each%20data%20type%20and%20takes%20the%20logs%20from%20hours%200-23%20for%20the%20day%20in%20hourly%20blocks.%3C%2FLI%3E%0A%3CLI%3ECompose%20%232%20-%20The%20results%20are%20composed%20into%20a%20message%20for%20sending%20to%20the%20Blob.%3C%2FLI%3E%0A%3CLI%3ECreate%20Blob%20-%20A%20new%20Blob%20is%20created%20with%20the%20title%20of%20the%20data%20type%2C%20the%20date%2C%20and%20the%20hour%20for%20which%20the%20logs%20are%20from.%20These%20results%20are%20sent%20to%20the%20new%20Blob%20and%20will%20be%20housed%20in%20the%20container%20that%20you%20have%20named.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EDepending%20on%20how%20much%20data%20is%20within%20each%20table%2C%20the%20Playbook%20can%20take%202%20to%2010%20minutes%20per%20table%20depending%20on%20how%20much%20each%20table%20has.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EDeployment%20of%20the%20Template%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EThere%20are%20two%20options%20for%20deploying%20the%20template%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3Edeployment%20button%20directly%20in%20GitHub%3C%2FLI%3E%0A%3CLI%3Emanual%20deployment%20via%20deploying%20the%20JSON%20of%20the%20Playbook%20in%20the%20Azure%20Portal%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EIf%20using%20the%20manual%20option%2C%20please%20refer%20to%20the%20README%20for%20the%20Playbook.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EUsing%20an%20Existing%20Storage%20Account%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20the%20event%20that%20an%20existing%20storage%20account%20is%20preferred%2C%20it%20can%20be%20set%20up%20within%20the%20Playbook.%20The%20following%20must%20be%20done%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EGo%20to%20the%20Azure%20Portal%3C%2FLI%3E%0A%3CLI%3EGo%20to%20the%20Playbook%3C%2FLI%3E%0A%3CLI%3EGo%20to%20Logic%20App%20Designer%3C%2FLI%3E%0A%3CLI%3EGo%20into%20the%20loop%3C%2FLI%3E%0A%3CLI%3EGo%20to%20the%20Blob%20action%3C%2FLI%3E%0A%3CLI%3EClick%20on%20'change%20connection'%3C%2FLI%3E%0A%3CLI%3EClick%20add%20new%3C%2FLI%3E%0A%3CLI%3EChoose%20the%20desired%20storage%20account%3C%2FLI%3E%0A%3CLI%3EGive%20the%20connection%20a%20name%3C%2FLI%3E%0A%3CLI%3EClick%20create%3C%2FLI%3E%0A%3CLI%3EUpdate%20the%20container%20name%20to%20be%20one%20from%20the%20existing%20storage%20account%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EGranting%20Permissions%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20Playbook%20is%20going%20to%20need%20proper%20permissions%20to%20run.%20It%20requires%20at%20least%20Blob%20Storage%20Contributor%20in%20order%20to%20create%20new%20Blobs%20within%20the%20data%20container.%20In%20order%20to%20provide%20the%20permissions%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EGo%20to%20the%20Azure%20Portal%3C%2FLI%3E%0A%3CLI%3EGo%20to%20Logic%20Apps%3C%2FLI%3E%0A%3CLI%3EChoose%20the%20Logic%20App%3C%2FLI%3E%0A%3CLI%3EGo%20to%20identity%3C%2FLI%3E%0A%3CLI%3EEnable%20'system%20assigned'%20identity%3C%2FLI%3E%0A%3CLI%3EClick%20save%3C%2FLI%3E%0A%3CLI%3EGo%20to%20either%20the%20subscription%20or%20the%20resource%20group%20that%20the%20storage%20account%20that%20is%20being%20used%20is%20in%3C%2FLI%3E%0A%3CLI%3EGo%20to%20access%20control%3C%2FLI%3E%0A%3CLI%3EClick%20add%3C%2FLI%3E%0A%3CLI%3EChoose%20add%20role%20assignment%3C%2FLI%3E%0A%3CLI%3EUnder%20'assign%20access%20to'%20choose%20Logic%20App%3C%2FLI%3E%0A%3CLI%3EFind%20your%20Logic%20App%3C%2FLI%3E%0A%3CLI%3ESelect%20it%3C%2FLI%3E%0A%3CLI%3EChoose%20the%20role%20'Blob%20storage%20data%20contributor'%3C%2FLI%3E%0A%3CLI%3EClick%20assign%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EQuery%20the%20data%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Query%20data.gif%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F193664i5F875739F0134852%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22Query%20data.gif%22%20alt%3D%22Querying%20the%20data%20from%203%20different%20blobs%20in%20order%20to%20see%20the%20data%20that%20was%20stored.%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EQuerying%20the%20data%20from%203%20different%20blobs%20in%20order%20to%20see%20the%20data%20that%20was%20stored.%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EOnce%20the%20data%20is%20in%20storage%2C%20it%20is%20still%20possible%20to%20query%20the%20day%20but%20in%20a%20smaller%20capacity.%20Querying%20the%20data%20now%20uses%20an%20operator%20called%20%E2%80%98externaldata%E2%80%99%20which%20requires%20you%20to%20use%20a%20SAS%20token%20URL%20generated%20by%20the%20Blob%20in%20order%20to%20pull%20the%20data%20from%20it.%20The%20process%20also%20requires%20that%20each%20column%20be%20defined%20so%20that%20it%20can%20properly%20map%20the%20data%20to%20the%20correct%20column.%20An%20example%20of%20what%20the%20query%20would%20look%20like%20would%20be%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3Elet%20ActivityLogs%20%3D%20externaldata%20(TimeGenerated%3Adatetime%2C%20OperationName%3Astring%2C%20OperationNameValue%3Astring%2C%20Level%3Astring%2C%20ActivityStatus%3Astring%2C%20SubscriptionID%3Astring)%5B%40%22SAS%20TOKEN%20URL%20FOR%20BLOB%22%5D%20with%20(format%3D%22multijson%22%2Crecreate_schema%3Dtrue)%3B%20ActivityLogs%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EThis%20query%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ECreates%20a%20variable%20that%20will%20become%20the%20table%3C%2FLI%3E%0A%3CLI%3EEstablishes%20what%20the%20columns%20will%20be%20and%20their%20value%20type%3C%2FLI%3E%0A%3CLI%3EOnce%20the%20columns%20are%20made%2C%20the%20SAS%20token%20URL%20is%20inserted%3C%2FLI%3E%0A%3CLI%3EMultiple%20URLs%20can%20be%20inserted%20in%20order%20to%20pull%20from%20multiple%20Blobs.%20Just%20separate%20the%20two%20by%20a%20comma%20and%20have%20them%20in%20their%20own%20quotations%3CUL%3E%0A%3CLI%3E%5B%40%E2%80%9Dlink%201%E2%80%9D%2C%E2%80%9Dlink%202%E2%80%9D%5D%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3EThe%20query%20then%20calls%20the%20table%20that%20you%20have%20created%2C%20this%20pulls%20in%20the%20logs%20from%20the%20Blob%20and%20routes%20the%20data%20to%20the%20columns%20that%20were%20created%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EThis%20query%20is%20going%20to%20pull%20the%20AzureActivity%20information%20from%20the%20Blob%20and%20maps%20the%20data%20to%20the%20associated%20columns.%20It%20is%20recommended%20to%20base%20your%20schema%20on%20the%20existing%20tables%20that%20were%20backed%20up%20in%20order%20to%20avoid%20any%20issues%20with%20parsing%20the%20data.%20In%20this%20case%2C%20AzureActivity%20was%20used%20as%20the%20reference%20for%20the%20associated%20logs%20that%20were%20in%20storage.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EMore%20information%20about%20external%20data%3A%26nbsp%3B-ERR%3AREF-NOT-FOUND-%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdata-explorer%2Fkusto%2Fquery%2Fexternaldata-operator%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdata-explorer%2Fkusto%2Fquery%2Fexternaldata-operator%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ESummary%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWith%20this%20Playbook%2C%20you%20now%20have%20control%20over%20logs%20being%20moved%20into%20long-term%20storage.%20This%20will%20be%20handy%20for%20existing%20data%20that%20is%20in%20the%20workspace%20that%20Sentinel%20is%20using%20when%20the%20retention%20period%20for%20the%20data%20runs%20out.%20This%2C%20in%20combination%20with%20the%20ability%20to%20query%20data%20from%20cold%20storage%2C%20allows%20for%20regulatory%20compliance%20and%20reduced%20costs%20while%20maintaining%20Sentinel%20log%20and%20Log%20Analytics%20usage%20for%20business%20operations.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20solution%20would%20not%20have%20been%20possible%20without%20the%20effort%20and%20great%20help%20from%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F19686%22%20target%3D%22_blank%22%3E%40Matt%20Egen%3C%2FA%3E%2C%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F89690%22%20target%3D%22_blank%22%3E%40Chris%20Boehm%3C%2FA%3E%26nbsp%3B%2C%20and%20Rin%20Ure.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1407153%22%20slang%3D%22en-US%22%3E%3CP%3ELearn%20about%20and%20deploy%20this%20new%20Playbook%20that%20allows%20you%20to%20move%20important%20Azure%20Sentinel%20logs%20to%20storage%20for%20long-term%2C%20cost%20effective%20retention.%3C%2FP%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%22Storage.gif%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F193684i03E6510DBFE42017%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22Storage.gif%22%20alt%3D%22Storage.gif%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1407153%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20Sentinel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ECold%20Storage%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Elogs%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ERetention%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

*Note: the initial template had an error regarding the end date. It is listed as -28, it will need to be changed to -88. The template has been updated in GitHub to reflect this.

 

Out of the box, Azure Sentinel provides 90 days of data retention for free. In some parts of the world and within certain industries, there are regulations that organizations must adhere to which require data retention up to 7 years or longer. The current challenge is that the max retention for Log Analytics workspaces is 2 years. There has been a need for a solution that will allow for more time and cost saving by moving logs to cold storage. This blog is going to detail how logs from a Log Analytics workspace can easily be moved into long-term cold storage in order to comply with retention standards as well as reduce costs using this Playbook.

 

End Results:

Logs are put into Blobs within folders that are labeled by data type.Logs are put into Blobs within folders that are labeled by data type.

This post is going to be in-depth as it breaks down how the Playbook is going to operate.

 

TL:DR The end result once the Playbook is run is a folder system with Blobs within a storage account and container. The folders are labeled with and contain the data types that have been chosen for back up. Each Blob in the folder will contain a backup of logs for each data type in hourly blocks. Each Blob can be queried in a Log Analytics workspace using the externaldata operator and a SAS token URL generated for the Blob.

 

Link for the Playbook if needed: https://github.com/Azure/Azure-Sentinel/tree/master/Playbooks/Move-LogAnalytics-to-Storage

 

*Note: If your Blobs are a size of 2B, there was no information for that time block or data type.

 

Pre-requisites:

  • Log Analytics Workspace
  • Azure Storage Account or permissions to create a new one
  • One storage container or permissions to create one
  • The Logic App

For auditing and investigative purposes, raw data and logs may need to be stored long term for regulatory compliance. This can be achieved through a Playbook that queries the logs from the workspace that are about to expire and moves them to a storage account of your choosing. The Playbook utilizes Log Analytics API when performing the query. An important piece of information to note is that the API has a limitation of 500,000 rows of data per request. This means that if any data type contains more than 500,000 rows of information, it will require the Playbook to run a Log Analytics API pull more than once to get the data. In order to avoid this issue, the Playbook breaks up data for each day into hourly blocks in order to efficiently and carefully back up all desired data. Each time that the Playbook is run, it reviews each data type within your workspace that should be backed up, goes through the logs for those data types, and moves the logs to storage, labeling each backup with the data type, the date of the log, and the hour for the time block.

Matt_Lowe_0-1592184465562.png

Matt_Lowe_1-1592184507352.png

 

The app is comprised of many steps and variables in order for it to work. The pieces are the following:

  • Recurrence trigger - Automatically run the app daily without needing manual input.
  • hoursCount - Counter variable that is used for tracking which hour the Playbook is on for exporting data. Starts at 0 for midnight and caps at 24.
  • startDate - Oldest date in a range that the queries will be using. Value is set to the current date minus 89 days (formatDateTime(addDays(utcNow(), -89),'yyyy-MM-dd')). This serves as the starting point for the time range to pull data from.
  • endDate - Similar to startDate, this variable serves to be the tail end of the time range. This value is set to the current date minus 88 days (formatDateTime(addDays(utcNow(), -88),'yyyy-MM-dd')). The time range between startDate and endDate are now 89 days ago and 88 days ago. The purpose for this is to move logs to storage 24 hours before they are deleted from the workspace.
  • excludedDataType - This variable is used to hold a list of data types that should not be backed up when running the Playbook. The list of options will be used in the query that checks to see which data types should be backed up. It is recommended that the data types chosen are logs that are noisy or are not important.
  • Query #1 - This query sets which log types should not be included based on the excluded variable. The query then checks the usage details to see which data is present in the workspace between 89 days ago and 88 days ago.
  • Compose - Composes the data for parsing for future use in the app.
  • Parse JSON - Parses the message from the query so that each item from the query results can be referenced later in the Playbook. The sample JSON for the step is provided in the template.
  • All of the details are then passed into a ForEach loop that then goes into an until loop that checks if hoursCount is 24. Each time that the logs are exported for a data type, it will increment the counter by 1 until it hits 24, then moves onto the next data type.
  • Query #2 - This query takes in the value of each data type and takes the logs from hours 0-23 for the day in hourly blocks.
  • Compose #2 - The results are composed into a message for sending to the Blob.
  • Create Blob - A new Blob is created with the title of the data type, the date, and the hour for which the logs are from. These results are sent to the new Blob and will be housed in the container that you have named.

Depending on how much data is within each table, the Playbook can take 2 to 10 minutes per table depending on how much each table has.

 

Deployment of the Template:

There are two options for deploying the template:

  • deployment button directly in GitHub
  • manual deployment via deploying the JSON of the Playbook in the Azure Portal

If using the manual option, please refer to the README for the Playbook.

 

Using an Existing Storage Account:

 

In the event that an existing storage account is preferred, it can be set up within the Playbook. The following must be done:

  • Go to the Azure Portal
  • Go to the Playbook
  • Go to Logic App Designer
  • Go into the loop
  • Go to the Blob action
  • Click on 'change connection'
  • Click add new
  • Choose the desired storage account
  • Give the connection a name
  • Click create
  • Update the container name to be one from the existing storage account

 

Granting Permissions:

 

The Playbook is going to need proper permissions to run. It requires at least Blob Storage Contributor in order to create new Blobs within the data container. In order to provide the permissions:

  • Go to the Azure Portal
  • Go to Logic Apps
  • Choose the Logic App
  • Go to identity
  • Enable 'system assigned' identity
  • Click save
  • Go to either the subscription or the resource group that the storage account that is being used is in
  • Go to access control
  • Click add
  • Choose add role assignment
  • Under 'assign access to' choose Logic App
  • Find your Logic App
  • Select it
  • Choose the role 'Blob storage data contributor'
  • Click assign

 

Query the data:

Querying the data from 3 different blobs in order to see the data that was stored.Querying the data from 3 different blobs in order to see the data that was stored.

Once the data is in storage, it is still possible to query the day but in a smaller capacity. Querying the data now uses an operator called ‘externaldata’ which requires you to use a SAS token URL generated by the Blob in order to pull the data from it. The process also requires that each column be defined so that it can properly map the data to the correct column. An example of what the query would look like would be:

  • let ActivityLogs = externaldata (TimeGenerated:datetime, OperationName:string, OperationNameValue:string, Level:string, ActivityStatus:string, SubscriptionID:string)[@"SAS TOKEN URL FOR BLOB"] with (format="multijson",recreate_schema=true); ActivityLogs

This query

  • Creates a variable that will become the table
  • Establishes what the columns will be and their value type
  • Once the columns are made, the SAS token URL is inserted
  • Multiple URLs can be inserted in order to pull from multiple Blobs. Just separate the two by a comma and have them in their own quotations
    • [@”link 1”,”link 2”]
  • The query then calls the table that you have created, this pulls in the logs from the Blob and routes the data to the columns that were created

This query is going to pull the AzureActivity information from the Blob and maps the data to the associated columns. It is recommended to base your schema on the existing tables that were backed up in order to avoid any issues with parsing the data. In this case, AzureActivity was used as the reference for the associated logs that were in storage.

 

More information about external data: https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/externaldata-operator

 

Summary:

 

With this Playbook, you now have control over logs being moved into long-term storage. This will be handy for existing data that is in the workspace that Sentinel is using when the retention period for the data runs out. This, in combination with the ability to query data from cold storage, allows for regulatory compliance and reduced costs while maintaining Sentinel log and Log Analytics usage for business operations.

 

This solution would not have been possible without the effort and great help from @Matt Egen@Chris Boehm , and Rin Ure.

10 Comments
Microsoft

Date from template is using incorrect date from my testing. It should be -88 days, it is currently listed as -28 days. Will be updating today.

 

 

*Issue has been fixed. If you have deployed the template, please make sure that you have the correct enddate of -88, not -28*

Regular Visitor

Hi @Matt_Lowe ! Thanks so much for posting this.

 

After deploying the logic app, I'm getting a bad request error on the first run:

 

"Message": "User input is invalid. Please check query syntax, Chart Type or other parameters data. Response Status=HttpJsonResponse: ResultStatus=NotFound, Response Content={\r\n  \"error\": {\r\n    \"code\": \"SubscriptionNotFound\",\r\n    \"message\": \"The subscription 'XXX-XX-SUB1' could not be found.\"\r\n  }\r\n}\r\nclientRequestId: 8e129f9c-17a8-4972-ba79-166c1e6fbf49"
 
Microsoft

@acoggins Thanks for bringing this up. Is this error message tied to the Azure Monitor action? It appears there might have been an issue with getting the subscription ID into the parameters for the query. If you go back to the designer > Azure Monitor, make sure that the subscription name is listed there and has a drop down arrow and not an 'x'. If possible, please paste a screenshot of the issue so that I can make sure that I am helping you with the right thing.

 

Matt_Lowe_0-1592507302052.png

 

Regular Visitor

They do have an X and not a dropdown! How do I update that? @Matt_Lowe 

acoggins_0-1592507508445.png

 

Microsoft

@acoggins click the x's and the drop down option will appear. Choose the subscription that you were trying to choose the first time and the rest of the items should be fixed. If not, click on the x's for those too and choose the correct options that you were trying to use. Let me know if that helps!

Regular Visitor

@Matt_Lowe that solved it! Thank you so much! We were just discussing how to make sure our Sentinel logs were stored long term, so your posting is very timely :smile:

Microsoft

Glad this could be of use! Let me know how it goes in your environment and if you have any suggestions on improvements. 

Occasional Visitor

@Matt_Lowe Thanks for sharing this ... I'm using this to move logs to storage from sentinel and want to use SP instead of user. Do you know what specific permissions I need to assign to the SP?

 

I tested it with AAD SP with higher privileges with some observations...

 

- On the connection steps it doesn't let me save it if I do a SP based connection in the 'designer view' but using the code view allows to save it and I can move further... 

- I have to Authorize the two API endpoints for 'azure monitor'

 

Occasional Visitor

@Matt_Lowe  hi.

Seems  Azure Log Analytics  Connector for LogicApps DEPRECATED. 

https://docs.microsoft.com/en-us/connectors/azureloganalytics/

Occasional Contributor

@Matt_Lowe Thanks for the write-up, this is very help and I think it would be great to have this capability built into Sentinel. We are running into one issue with our deployment of this. Under the step 'Run query and list results 2' we are receiving the following error for some of our data tables. It sounds like it means that the table during the hour period is too large to call.

 

BadRequest. Http request failed as there is an error: 'Cannot write more bytes to the buffer than the configured maximum buffer size: 104857600.'.

 

Thanks