%3CLINGO-SUB%20id%3D%22lingo-sub-1212240%22%20slang%3D%22en-US%22%3ERe%3A%20Troubleshooting%20Common%20issues%20with%20Elastic%20Jobs%20in%20Azure%20SQL%20Database%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1212240%22%20slang%3D%22en-US%22%3E%3CDIV%20class%3D%22user-mention-tag%22%3E%3CP%20class%3D%22user-mention-tag-label%22%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F553780%22%20target%3D%22_blank%22%3E%40Kate_Smith%3C%2FA%3E%2C%3C%2FP%3E%3CP%20class%3D%22user-mention-tag-label%22%3EThis%20is%20such%20a%20thorough%20explanation%20of%20this%20subject.%26nbsp%3B%20Thank%20you%20for%20publishing%20it!%3C%2FP%3E%3CP%20class%3D%22user-mention-tag-label%22%3E%26nbsp%3B%3C%2FP%3E%3CP%20class%3D%22user-mention-tag-label%22%3EBTW%2C%20'Rules'%20is%20misspelled%20in%20'Fixing%20the%20Firewall%20Rultes.'%3C%2FP%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1216022%22%20slang%3D%22en-US%22%3ERe%3A%20Troubleshooting%20Common%20issues%20with%20Elastic%20Jobs%20in%20Azure%20SQL%20Database%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1216022%22%20slang%3D%22en-US%22%3E%3CP%3EInformative%20Thanks%20Kate%20!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1180766%22%20slang%3D%22en-US%22%3ETroubleshooting%20Common%20issues%20with%20Elastic%20Jobs%20in%20Azure%20SQL%20Database%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1180766%22%20slang%3D%22en-US%22%3E%3CTABLE%20style%3D%22border-style%3A%20double%3B%20width%3A%20100%25%3B%22%20border%3D%221%22%20width%3D%22100%25%22%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22100%25%22%3E%3CFONT%20style%3D%22box-sizing%3A%20border-box%3B%20color%3A%20%23ff0000%3B%20font-family%3A%20%26amp%3Bquot%3B%20segoeui%26amp%3Bquot%3B%2C%26amp%3Bquot%3Blato%26amp%3Bquot%3B%2C%26amp%3Bquot%3Bhelvetica%20neue%26amp%3Bquot%3B%2Chelvetica%2Carial%2Csans-serif%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%20color%3D%22%23ff0000%22%3EElastic%20Jobs%20are%20currently%20in%20public%20preview.%26nbsp%3B%20The%20feature%20is%20ready%20and%20we%20are%20preparing%20to%20make%20it%20officially%20generally%20available.%26nbsp%3B%20No%20extra%20steps%20are%20required%20to%20get%20started.%3C%2FFONT%3E%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20style%3D%22box-sizing%3A%20border-box%3B%20color%3A%20%23333333%3B%20font-family%3A%20%26amp%3Bquot%3B%20segoeui%26amp%3Bquot%3B%2C%26amp%3Bquot%3Blato%26amp%3Bquot%3B%2C%26amp%3Bquot%3Bhelvetica%20neue%26amp%3Bquot%3B%2Chelvetica%2Carial%2Csans-serif%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%20color%3D%22%23333333%22%3E%3CSTRONG%20style%3D%22box-sizing%3A%20border-box%3B%20font-weight%3A%20bold%3B%22%3E%3CFONT%20size%3D%225%22%20style%3D%22box-sizing%3A%20border-box%3B%22%3EDetermining%20the%20Cause%20of%20Failure%3C%2FFONT%3E%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3EAssume%20for%20the%20purposes%20of%20demonstration%20that%20I%20have%20created%20a%20job%20with%20a%20typo%20(missing%20parenthesis%20before%20the%20CREATE)%20in%20it%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22WrongTextPowerShell.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F171911i3694A8025E9C0433%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22WrongTextPowerShell.png%22%20alt%3D%22WrongTextPowerShell.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20run%20the%20job%20several%20times%2C%20but%20it%20fails.%20We%20can%20see%20this%20in%20the%20portal%2C%20or%20through%20Azure%20Cloud%20Shell%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22JobsFailed.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F171910i917AC7C61F8FF9B3%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22JobsFailed.png%22%20alt%3D%22JobsFailed.png%22%20%2F%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22JobsFailedCloudShell.png%22%20style%3D%22width%3A%20887px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F171909i58D57194A6EC01AA%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22JobsFailedCloudShell.png%22%20alt%3D%22JobsFailedCloudShell.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20can%20confirm%20the%20failure%20by%20issuing%20the%20following%20query%20in%20Sql%20Server%20Management%20Studio%20when%20connected%20to%20the%20job%20database%20(this%20hosts%20my%20Elastic%20Jobs%20agent)%20directly%3A%3C%2FP%3E%0A%3CP%3E%E2%80%AF%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3ESELECT%20*%26nbsp%3B%26nbsp%3B%3CBR%20%2F%3EFROM%20jobs.job_executions%26nbsp%3B%26nbsp%3B%3CBR%20%2F%3EWHERE%20job_name%20%3D%20'demo123'%3CBR%20%2F%3EORDER%20BY%20start_time%20DESC%26nbsp%3B%3C%2FPRE%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%22JobsFailedSSMS.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F171908i0A5BDA52804F3183%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22JobsFailedSSMS.png%22%20alt%3D%22JobsFailedSSMS.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EUsing%20any%20of%20these%20three%20methods%20confirms%20that%20the%20job%20failed.%20So%2C%20the%20first%20step%20is%20to%20drill%20down%20onto%20the%20failure%20message%20by%20executing%20the%20following%20query%3A%3C%2FP%3E%0A%3CP%3E%E2%80%AF%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3ESELECT%20last_message%26nbsp%3B%26nbsp%3B%3CBR%20%2F%3EFROM%20jobs.job_executions%26nbsp%3B%3CBR%20%2F%3EWHERE%20job_name%20%3D%20'demo123'%26nbsp%3BAND%20step_name%20%26lt%3B%26gt%3B%20'NULL'%3C%2FPRE%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%22FirewallFailureMessageSSMS.png%22%20style%3D%22width%3A%20714px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F171907iF345E75DCCBFDA1E%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22FirewallFailureMessageSSMS.png%22%20alt%3D%22FirewallFailureMessageSSMS.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%E2%80%AFThis%20yields%20the%20following%20error%20message%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%3C%2FP%3E%0A%3CTABLE%20border%3D%221%22%20width%3D%22100%25%22%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22100%25%22%3E%3CSPAN%20style%3D%22display%3A%20inline%20!important%3B%20float%3A%20none%3B%20background-color%3A%20%23ffffff%3B%20color%3A%20%23333333%3B%20cursor%3A%20text%3B%20font-family%3A%20inherit%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20line-height%3A%201.7142%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3EFailed%20to%20determine%20members%20of%20SqlServerTarget%20(server%20name%20'targetserver'%2C%20server%20location%20'targetserver.database.windows.net')%3A%20Cannot%20open%20server%20'targetserver'%20requested%20by%20the%20login.%20Client%20with%20IP%20address%20'13.89.57.50'%20is%20not%20allowed%20to%20access%20the%20server.%20To%20enable%20access%2C%20use%20the%20Windows%20Azure%20Management%20Portal%20or%20run%20sp_set_firewall_rule%20on%20the%20master%20database%20to%20create%20a%20firewall%20rule%20for%20this%20IP%20address%20or%20address%20range.%20It%20may%20take%20up%20to%20five%20minutes%20for%20this%20change%20to%20take%20effect.%20(Msg%2040615%2C%20Level%2014%2C%20State%201%2C%20Line%2065536)%E2%80%AF%3C%2FSPAN%3E%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20style%3D%22box-sizing%3A%20border-box%3B%20color%3A%20%23333333%3B%20font-family%3A%20%26amp%3Bquot%3B%20segoeui%26amp%3Bquot%3B%2C%26amp%3Bquot%3Blato%26amp%3Bquot%3B%2C%26amp%3Bquot%3Bhelvetica%20neue%26amp%3Bquot%3B%2Chelvetica%2Carial%2Csans-serif%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%20color%3D%22%23333333%22%3E%3CSTRONG%20style%3D%22box-sizing%3A%20border-box%3B%20font-weight%3A%20bold%3B%22%3E%3CFONT%20size%3D%225%22%20style%3D%22box-sizing%3A%20border-box%3B%22%3EFixing%20the%20Firewall%20Rules%3C%2FFONT%3E%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3EThis%20error%20means%20that%20the%20Elastic%20Job%20Agent%20cannot%20connect%20to%20the%20target%20server(s)%20because%20the%20target%20has%20some%20firewall%20rules%20blocking%20the%20connection%20requests.%26nbsp%3B%20Indeed%20-%20it%20is%20required%20that%20every%20target%20in%20the%20target%20group%20allows%20connections%20from%20Azure%20Services%20in%20order%20for%20Elastic%20Jobs%20to%20work.%26nbsp%3B%20To%20fix%20this%2C%20I%20go%20to%20the%20target%20server%20in%20the%20Azure%20Portal%20and%20click%20on%20the%20%E2%80%9CFirewalls%20and%20virtual%20networks%E2%80%9D%20item%20under%20%E2%80%9CSecurity%E2%80%9D.%26nbsp%3B%20Next%2C%20I%20toggle%20the%20%22Allow%20Azure%20services%22%20from%20OFF%20to%20ON%2C%20and%20save%20my%20changes.%20%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%E2%80%AF%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22FirewallTogglePortal.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F171916i50FAA2749A3123B9%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22FirewallTogglePortal.png%22%20alt%3D%22FirewallTogglePortal.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20style%3D%22box-sizing%3A%20border-box%3B%20color%3A%20%23333333%3B%20font-family%3A%20%26amp%3Bquot%3B%20segoeui%26amp%3Bquot%3B%2C%26amp%3Bquot%3Blato%26amp%3Bquot%3B%2C%26amp%3Bquot%3Bhelvetica%20neue%26amp%3Bquot%3B%2Chelvetica%2Carial%2Csans-serif%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%20color%3D%22%23333333%22%3E%3CSTRONG%20style%3D%22box-sizing%3A%20border-box%3B%20font-weight%3A%20bold%3B%22%3E%3CFONT%20size%3D%225%22%20style%3D%22box-sizing%3A%20border-box%3B%22%3EFixing%20Typos%20or%20Syntax%20Errors%20in%20Job%20Steps%3C%2FFONT%3E%3C%2FSTRONG%3E%3C%2FFONT%3E%E2%80%AF%3C%2FP%3E%0A%3CP%3ENow%2C%20we%20re-execute%20the%20job%2C%20but%20the%20execution%20fails%20again.%26nbsp%3B%20If%20I%20use%20SQL%20Server%20Management%20Studio%20to%20execute%20the%20same%20query%20as%20before%2C%20I%20can%20get%20the%20most%20recent%20failure%20message.%26nbsp%3B%20This%20time%2C%20the%20error%20is%3A%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CTABLE%20border%3D%221%22%20width%3D%22100%25%22%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22100%25%22%3E%3CSPAN%20style%3D%22display%3A%20inline%20!important%3B%20float%3A%20none%3B%20background-color%3A%20%23ffffff%3B%20color%3A%20%23333333%3B%20cursor%3A%20text%3B%20font-family%3A%20inherit%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20line-height%3A%201.7142%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3ECommand%20failed%3A%20Incorrect%20syntax%20near%20the%20keyword%20'create'.%20(Msg%20156%2C%20Level%2015%2C%20State%201%2C%20Line%201)%26nbsp%3B%3C%2FSPAN%3E%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3E%E2%80%AF%26nbsp%3B%3C%2FP%3E%0A%3CP%3ERecall%20that%20we%20expected%20this%2C%20since%20we%20knew%20there%20was%20a%20typo%20in%20the%20T-SQL%20used%20to%20define%20the%20step.%26nbsp%3B%20I%20am%20going%20to%20update%20the%20T-SQL%20with%20the%20correct%20parenthesis.%26nbsp%3B%20There%20are%20two%20ways%20to%20update%20a%20job%20step%20when%20you%20want%20to%20make%20this%20kind%20of%20a%20change%20-%20T-SQL%20or%20PowerShell.%26nbsp%3B%20If%20you%20are%20using%20T-SQL%2C%20you%20will%20want%20to%20use%20the%20stored%20procedure%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsql-database%2Felastic-jobs-tsql%23sp_update_jobstep%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ejobs.sp_update_jobstep%3C%2FA%3E%26nbsp%3B.%26nbsp%3B%20In%20PowerShell%20you%20will%20use%20the%20%3CSPAN%20style%3D%22display%3A%20inline%20!important%3B%20float%3A%20none%3B%20background-color%3A%20%23ffffff%3B%20color%3A%20%23333333%3B%20cursor%3A%20text%3B%20font-family%3A%20inherit%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20line-height%3A%201.7142%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3ESet-AzSqlElasticJobStep%3C%2FSPAN%3E%20command%20from%20the%20specific%20job%20step%20you%20want%20to%20change.%26nbsp%3B%20I%20am%20going%20to%20update%20my%20job%20step%20using%20PowerShell.%26nbsp%3B%20To%20do%20this%2C%20first%20we%20need%20to%20bind%20the%20correct%20T-SQL%20text%2C%20then%20bind%20the%20specific%20job%20step%20we%20want%20to%20change%2C%20and%20then%20update%20it%3A%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3A%5C%26gt%3B%20%24sqlText1%20%3D%20%22if%20not%20exists%20(select%20*%20from%20sys.Tables%20where%20object_id%20%3D%20object_id('T'))%20create%20table%20T%20(a%20int%2C%20b%20int)%22%26nbsp%3B%3CBR%20%2F%3E%3A%5C%26gt%3B%20%24js%20%3D%20%24job%20%7C%20Get-AzSqlElasticJobStep%20-Name%20step1%3CBR%20%2F%3E%3A%5C%26gt%3B%20%24js%20%7C%20Set-AzSqlElasticJobStep%20-CommandText%20%24sqlText1%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENow%20that%20the%20job%20step%20has%20been%20updated%2C%20we%20wait%20for%20all%20running%20instances%20of%20the%20job%20to%20complete%20(if%20there%20are%20any)%20and%20re-run%20the%20job.%26nbsp%3B%20And%2C%20of%20course%2C%20check%20on%20its%20execution.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3A%5C%26gt%3B%20%24job%20%7C%20Start-AzSqlElasticJob%26nbsp%3B%3C%2FPRE%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%22UpdateAndRerunPowerShell.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F171904i5FBF99F0F5EEAE63%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22UpdateAndRerunPowerShell.png%22%20alt%3D%22UpdateAndRerunPowerShell.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENext%2C%20we%20can%20check%20the%20status%20by%20executing%20our%20query%20about%20job%20executions%20from%20Management%20Studio.%26nbsp%3B%20Note%20the%20job_version%20is%20now%202%20instead%20of%201%20(because%20of%20the%20update).%26nbsp%3B%20The%20job%20is%20running%2C%20and%20can%20complete%20successfully.%3C%2FP%3E%0A%3CP%3E%E2%80%AF%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22JobVersion2.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F171903iF7AF7657371D5600%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22JobVersion2.png%22%20alt%3D%22JobVersion2.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%E2%80%AF%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20post%20concludes%20my%20series%20covering%20Elastic%20Jobs%20on%20Azure%20SQL%20Database.%20I%20hope%20that%20you%20found%20it%20informative%20and%20helpful.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20blog%20is%20part%20of%20a%20series%20about%20Elastic%20Jobs%20on%20Azure%20SQL%20Database.%3C%2FP%3E%0A%3CP%3ECode%20samples%20are%20also%20available%20on%20-ERR%3AREF-NOT-FOUND-GitHub.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-sql-database%2Felastic-jobs-in-azure-sql-database-what-and-why%2Fba-p%2F1177902%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3EElastic%20Jobs%20in%20Azure%20SQL%20Database%20%E2%80%93%20What%20and%20Why%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-sql-database%2Ffundamental-concepts-for-elastic-jobs-in-azure-sql-database%2Fba-p%2F1177939%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3EFundamental%20Concepts%20for%20Elastic%20Jobs%20in%20Azure%20SQL%20Database%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-sql-database%2Fcreating-an-elastic-jobs-agent-credentials-and-jobs-for-azure%2Fba-p%2F1179929%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3ECreating%20an%20Elastic%20Jobs%20Agent%2C%20Credentials%2C%20and%20Jobs%20for%20Azure%20SQL%20Database%20in%20PowerShell%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-sql-database%2Fcreating-an-elastic-jobs-agent-credentials-and-jobs-for-azure%2Fba-p%2F1180096%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3ECreating%20an%20Elastic%20Jobs%20Agent%2C%20Credentials%2C%20and%20Jobs%20for%20Azure%20SQL%20Database%20using%20T-SQL%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-sql-database%2Frunning-scheduling-and-monitoring-elastic-jobs-in-azure-sql%2Fba-p%2F1180179%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3ERunning%2C%20Scheduling%20and%20Monitoring%20Elastic%20Jobs%20in%20Azure%20SQL%20Database%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-sql-database%2Ftroubleshooting-common-issues-with-elastic-jobs-in-azure-sql%2Fba-p%2F1180766%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3ETroubleshooting%20Common%20issues%20with%20Elastic%20Jobs%20in%20Azure%20SQL%20Database%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FOL%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1180766%22%20slang%3D%22en-US%22%3E%3CP%3ETo%20conclude%20my%20series%20on%20Elastic%20Jobs%20in%20Azure%20SQL%20Database%2C%20I%20will%20address%20how%20to%20monitor%20and%20drill%20down%20into%20failures.%20I%20will%20show%20you%20how%20to%20identify%20issues%2C%20and%20how%20to%20resolve%20a%20few%20common%20ones.%3C%2FP%3E%3C%2FLINGO-TEASER%3E
Microsoft
Elastic Jobs are currently in public preview.  The feature is ready and we are preparing to make it officially generally available.  No extra steps are required to get started.

 

Determining the Cause of Failure

Assume for the purposes of demonstration that I have created a job with a typo (missing parenthesis before the CREATE) in it:

WrongTextPowerShell.png

 

I run the job several times, but it fails. We can see this in the portal, or through Azure Cloud Shell:

JobsFailed.pngJobsFailedCloudShell.png

 

We can confirm the failure by issuing the following query in Sql Server Management Studio when connected to the job database (this hosts my Elastic Jobs agent) directly:

  

SELECT *  
FROM jobs.job_executions  
WHERE job_name = 'demo123'
ORDER BY start_time DESC 

 

JobsFailedSSMS.png

 

 

Using any of these three methods confirms that the job failed. So, the first step is to drill down onto the failure message by executing the following query:

  

SELECT last_message  
FROM jobs.job_executions 
WHERE job_name = 'demo123' AND step_name <> 'NULL'

 

FirewallFailureMessageSSMS.png

 

 This yields the following error message:

  

Failed to determine members of SqlServerTarget (server name 'targetserver', server location 'targetserver.database.windows.net'): Cannot open server 'targetserver' requested by the login. Client with IP address '13.89.57.50' is not allowed to access the server. To enable access, use the Windows Azure Management Portal or run sp_set_firewall_rule on the master database to create a firewall rule for this IP address or address range. It may take up to five minutes for this change to take effect. (Msg 40615, Level 14, State 1, Line 65536) 

 

Fixing the Firewall Rules

This error means that the Elastic Job Agent cannot connect to the target server(s) because the target has some firewall rules blocking the connection requests.  Indeed - it is required that every target in the target group allows connections from Azure Services in order for Elastic Jobs to work.  To fix this, I go to the target server in the Azure Portal and click on the “Firewalls and virtual networks” item under “Security”.  Next, I toggle the "Allow Azure services" from OFF to ON, and save my changes.  

  

FirewallTogglePortal.png

 

Fixing Typos or Syntax Errors in Job Steps

Now, we re-execute the job, but the execution fails again.  If I use SQL Server Management Studio to execute the same query as before, I can get the most recent failure message.  This time, the error is: 

 

Command failed: Incorrect syntax near the keyword 'create'. (Msg 156, Level 15, State 1, Line 1) 

  

Recall that we expected this, since we knew there was a typo in the T-SQL used to define the step.  I am going to update the T-SQL with the correct parenthesis.  There are two ways to update a job step when you want to make this kind of a change - T-SQL or PowerShell.  If you are using T-SQL, you will want to use the stored procedure jobs.sp_update_jobstep .  In PowerShell you will use the Set-AzSqlElasticJobStep command from the specific job step you want to change.  I am going to update my job step using PowerShell.  To do this, first we need to bind the correct T-SQL text, then bind the specific job step we want to change, and then update it: 

 

:\> $sqlText1 = "if not exists (select * from sys.Tables where object_id = object_id('T')) create table T (a int, b int)" 
:\> $js = $job | Get-AzSqlElasticJobStep -Name step1
:\> $js | Set-AzSqlElasticJobStep -CommandText $sqlText1

 

Now that the job step has been updated, we wait for all running instances of the job to complete (if there are any) and re-run the job.  And, of course, check on its execution.

 

:\> $job | Start-AzSqlElasticJob 

 

UpdateAndRerunPowerShell.png

 

Next, we can check the status by executing our query about job executions from Management Studio.  Note the job_version is now 2 instead of 1 (because of the update).  The job is running, and can complete successfully.

  

JobVersion2.png

 

  

This post concludes my series covering Elastic Jobs on Azure SQL Database. I hope that you found it informative and helpful.

 

This blog is part of a series about Elastic Jobs on Azure SQL Database.

Code samples are also available on GitHub.  

  1. Elastic Jobs in Azure SQL Database – What and Why
  2. Fundamental Concepts for Elastic Jobs in Azure SQL Database
  3. Creating an Elastic Jobs Agent, Credentials, and Jobs for Azure SQL Database in PowerShell
  4. Creating an Elastic Jobs Agent, Credentials, and Jobs for Azure SQL Database using T-SQL
  5. Running, Scheduling and Monitoring Elastic Jobs in Azure SQL Database
  6. Troubleshooting Common issues with Elastic Jobs in Azure SQL Database
2 Comments
Senior Member

@Kate_Smith,

This is such a thorough explanation of this subject.  Thank you for publishing it!

 

BTW, 'Rules' is misspelled in 'Fixing the Firewall Rultes.'

Senior Member

Informative Thanks Kate !