Home
%3CLINGO-SUB%20id%3D%22lingo-sub-740376%22%20slang%3D%22en-US%22%3EPolybase%20User%20Guide%20-%20Part%201%20%3A%20Secured%20Storage%20Account%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-740376%22%20slang%3D%22en-US%22%3E%3CP%3ECustomers%20are%20ever%20increasingly%20making%20use%20of%20Polybase%20to%20load%20data%20into%20the%20Azure%20Data%20Warehouse%2C%20Polybase%20is%20the%20go-to%20solution%20when%20attempting%20load%20large%20files%20and%20thousands%20to%20millions%20of%20records.%20The%20intention%20of%20this%20Guide%20is%20not%20explain%20what%20Polybase%20is%20and%20how%20it%20works%20if%20you%20require%20a%20deeper%20understanding%20of%20how%20it%20works%20or%20looking%20for%20more%20granular%20information%20on%20Polybase%20start%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Frelational-databases%2Fpolybase%2Fpolybase-guide%3Fview%3Dsql-server-2017%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20intention%20of%20this%20guide%20is%20to%20help%20you%20decide%20which%20Polybase%20configuration%20will%20fulfill%20your%20requirements.%20It%20will%20be%20a%20multi%20part%20guide%20and%20in%20each%20part%20of%20the%20guide%20I%20will%20review%20the%20credentials%2C%20the%20requirements%20and%20provide%20the%20examples%20and%20relevant%20articles%20which%20will%20make%20your%20implementation%20of%20Polybase%20hassle%20free.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20Part%202%20we%20will%20review%20Unrestricted%20storage%20and%20the%20original%20Polybase%20configuration%3C%2FP%3E%0A%3CP%3EIn%20Part%203%20we%20will%20review%20Integration%20tools%20which%20make%20use%20of%20Polybase%20to%20load%20data%20(ADF%2FDatabricks)%3C%2FP%3E%0A%3CP%3EIn%20Part%204%20we%20will%20review%20how%20to%20modify%20your%20existing%20Polybase%20configuration%20without%20recreation%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EPart%201%20%E2%80%93%20Secured%20Storage%20Account%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20Part%201%20we%20will%20focus%20on%20the%20most%20sought-after%20feature%20within%20Polybase%2C%20Connecting%20to%20a%20Secured%20storage%20account.%20The%20ability%20to%20connect%20to%20a%20secured%20storage%20account%20was%20generally%20available%20December%202018%20and%20has%20since%20caused%20much%20confusion%20due%20to%20the%20specific%20requirements%20to%20make%20this%20possible%2C%20none%20of%20which%20are%20difficult%20to%20implement%20and%20will%20require%20a%20once%20off%20configuration.%3C%2FP%3E%0A%3CP%3EIf%20you%20have%20a%20Secured%20storage%20account%20or%20want%20to%20secure%20your%20storage%20account%20and%20would%20like%20to%20make%20use%20of%20Polybase%20to%20load%20or%20read%20your%20external%20data%20the%20following%20steps%20are%20required%2C%20there%20is%20no%20other%20alternative%20or%20workaround.%20We%20went%20through%20extensive%20development%20and%20released%20multiple%20components%20to%20make%20this%20possible.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ERequirements%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThere%20are%202%20requirements%20which%20make%20this%20configuration%20possible%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3EGeneration%202%20Storage%20account%3C%2FSTRONG%3E%2C%20if%20you%20do%20not%20have%20a%20Generation%202%20storage%20account%20this%20will%20not%20be%20possible%2C%20upgrade%20to%20Gen2%20before%20going%20further%20following%20this%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fstorage%2Fcommon%2Fstorage-account-upgrade%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eguide%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EVNET%20Service%20Endpoints%3C%2FSTRONG%3Ewith%20Azure%20storage%20which%20is%20what%20I%20will%20be%20covering%20in%20this%20guide%20and%20is%20available%20for%20further%20reference%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsql-database%2Fsql-database-vnet-service-endpoint-rule-overview%3Ftoc%3D%2Fazure%2Fsql-data-warehouse%2Ftoc.json%23impact-of-using-vnet-service-endpoints-with-azure-storage%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EImplementation%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20Polybase%20engineering%20team%20released%20a%20new%20credential%20called%20Managed%20Service%20Identity%20as%20well%20as%20a%20new%20secure%20schema%20ABFSS%20which%20connects%20to%20an%20updated%20endpoint%20dfs.core.windows.net.%3C%2FP%3E%0A%3CP%3EUsing%20these%203%20components%20it%20is%20now%20possible%20for%20you%20to%20enable%20the%20storage%20firewall%20and%20limit%20access%20to%20Azure%20Services%20within%20your%20storage%20account.%20Polybase%20source%20connections%20from%20the%20Azure%20Data%20Warehouse%20do%20not%20fall%20with%20the%20standard%20Azure%20Service%20IP%20boundaries%20which%20is%20why%20this%20was%20previously%20not%20possible.%20%3CSTRONG%3E%26nbsp%3B%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CEM%3E(The%20same%20configuration%20is%20applicable%20to%20Blob%20Store%20and%20Data%20Lake%20there%20is%20no%20difference%20in%20the%20configuration)%3C%2FEM%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EDatabase%20Security%20Consideration%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBefore%20we%20proceed%20further%2C%20we%20need%20to%20address%20the%20permissions%20a%20user%20requires%20to%20create%20all%20the%20required%20objects.%26nbsp%3BTo%20make%20this%20easier%20and%20more%20manageable%20I%20would%20suggest%20creating%20a%20role%20within%20your%20Data%20Warehouse%20and%20making%20users%20role%20members%20which%20would%20avoid%20having%20to%20grant%20and%20revoke%20permissions%20individually%20as%20users%20are%20added%20or%20removed.%26nbsp%3B%20The%20permissions%20which%20are%20required%20are%20elevated%20and%20therefore%20I%20would%20advise%20that%20only%20Database%20Administrators%2C%20Senior%20Project%20Members%20or%20knowledgeable%20users%20are%20granted%20these%20permissions.%3C%2FP%3E%0A%3CP%3EBelow%20is%20all%20the%20permissions%20you%20will%20require%20within%20the%20database%2C%20the%20script%20will%20create%20the%20roll%2C%20assign%20the%20permissions%20to%20the%20role%20and%20add%20the%20role%20membership%20to%20the%20designed%20user%20account.%20Specify%20required%20Data%20Warehouse%20DB%20name%20and%20User%20account.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECreate%20Role%20Polybase_Users%26nbsp%3B%3C%2FP%3E%0A%3CP%3EGrant%20CREATE%20TABLE%20TO%20Polybase_Users%3C%2FP%3E%0A%3CP%3EGrant%20ALTER%20ANY%20SCHEMA%20TO%20Polybase_Users%3C%2FP%3E%0A%3CP%3EGrant%20ALTER%20ANY%20EXTERNAL%20DATA%20SOURCE%20TO%20Polybase_Users%3C%2FP%3E%0A%3CP%3EGrant%20ALTER%20ANY%20EXTERNAL%20FILE%20FORMAT%20TO%20Polybase_Users%3C%2FP%3E%0A%3CP%3EGrant%20CONTROL%20ON%20DATABASE%3A%3A%5B%5D%20TO%20Polybase_Users%3C%2FP%3E%0A%3CP%3Esp_addrolemember%20Polybase_Users%20%2C%20%3CYOURUSERNAME%3E%3C%2FYOURUSERNAME%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%26nbsp%3B%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EStep1%20%E2%80%93%20Create%20the%20MSI%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ERegister%20the%20Logical%20Database%20Server%20which%20hosts%20your%20Azure%20Data%20Warehouse%20within%20Azure%20Active%20directory%2C%20the%20identity%20will%20be%20used%20to%20authenticate%20with%20the%20storage%20account%20and%20grant%20you%20access%20to%20your%20external%20data%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20order%20to%20so%20run%20the%20following%20Powershell%20commands%2C%20you%20can%20run%20this%20from%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fazure%2Finstall-az-ps%3Fview%3Dazps-2.4.0%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Module%3C%2FA%3E%26nbsp%3Bif%20you%20have%20it%20installed%20or%20run%20the%20command%20from%20the%20Azure%20Portal%20using%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fcloud-shell%2Fquickstart-powershell%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3ECloudshell%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EConnect-AzAccount%3C%2FP%3E%0A%3CP%3ESelect-AzSubscription%20-SubscriptionId%20%3CYOUR-SUBSCRIPTIONID%3E%3C%2FYOUR-SUBSCRIPTIONID%3E%3C%2FP%3E%0A%3CP%3ESet-AzSqlServer%20-ResourceGroupName%20%3CYOUR-DATABASE-SERVER-RESOURCEGROUP%3E%20-ServerName%20%3CYOUR-DATABASE-SERVERNAME%3E%20-AssignIdentity%3C%2FYOUR-DATABASE-SERVERNAME%3E%3C%2FYOUR-DATABASE-SERVER-RESOURCEGROUP%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CEM%3E%26nbsp%3B(Note%3A%20You%20do%20not%20have%20to%20specify%20database.windows.net%20only%20the%20server%20name%20is%20required.%20Details%20provided%20on%20the%20Server%20Overview%20Pane)%3C%2FEM%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CEM%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20834px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F122381iED2087CC5A791B61%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22P1DWInfo.png%22%20title%3D%22P1DWInfo.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FEM%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EStep2%20%E2%80%93%20Grant%20the%20permissions%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWith%20the%20identity%20created%20you%20will%20now%20be%20able%20to%20grant%20the%20Identity%20access%20to%20the%20target%20storage%20account%20which%20I%20want%20to%20secure%20with%20a%20firewall.%20%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CEM%3ETo%20grant%20these%20permissions%2C%20the%20grantor%20must%20be%20a%20member%20of%20a%20group%20or%20role%20which%20has%20Owner%20Privileges.%20If%20you%20do%20not%20have%20such%20permissions%2C%20you%20would%20not%20be%20able%20to%20grant%20the%20Server%20MSI%20the%20required%20role.%3C%2FEM%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EWithin%20the%20storage%20account%20navigate%20to%20%3CSTRONG%3EAccess%20Control(IAM)%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3ESelect%20%3CSTRONG%3EAdd%20a%20Role%20Assignment%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSTRONG%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20347px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F122382iAF1B6428E77EFD12%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22ra.PNG%22%20title%3D%22ra.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ESelect%20%3CSTRONG%3EStorage%20Blob%20Data%20Contributor%3C%2FSTRONG%3Efrom%20the%20Role%20Dropdown%20list%3C%2FLI%3E%0A%3CLI%3ESearch%20for%20your%20%3CSTRONG%3E%3CSERVER%20name%3D%22%22%3E%3C%2FSERVER%3E%3C%2FSTRONG%3Ein%20the%20Select%20Search%20box%26nbsp%3B%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSTRONG%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20419px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F122383i449212114782A5D8%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22ara.PNG%22%20title%3D%22ara.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EOnce%20you%20have%20found%20the%20server%20name%20save%20the%20configuration%2C%20so%20permissions%20are%20applied.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EThe%20permissions%20have%20now%20been%20granted%20at%20a%20storage%20level%20to%20the%20Managed%20Service%20Identity%2C%20this%20will%20allow%20you%20to%20connect%20to%20the%20storage%20account.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EStep%203%20%E2%80%93%20Database%20Credential%20Configuration%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20next%20step%20is%20to%20configure%20the%20database%20credentials%20which%20will%20be%20used%20by%20your%20External%20Data%20Source%3C%2FP%3E%0A%3CP%3EIf%20you%20have%20never%20created%20any%20external%20objects%20and%20this%20is%20the%20first%20time%20you%20are%20configuring%20Polybase%20you%20have%20to%20start%20out%20by%20creating%20a%20Master%20Key%20within%20your%20database.%20(%3CEM%3EAzure%20Data%20Warehouse%20does%20not%20require%20a%20password%20to%20be%20specified%20for%20the%20Master%20Key.%20If%20you%20make%20use%20of%20a%20password%2C%20take%20record%20of%20the%20password%3C%2FEM%3E)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECREATE%20MASTER%20KEY%20%5BENCRYPTION%20BY%20PASSWORD%20%3D%20'somepassword'%5D%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOnce%20the%20key%20is%20created%20proceed%20with%20creating%20the%20credentials%20which%20will%20refer%20to%20the%20Managed%20Service%20Identity.%20It%20does%20not%20require%20you%20to%20specify%20a%20SECRET%20when%20you%20use%20the%20Managed%20Service%20Identity.%3C%2FP%3E%0A%3CP%3EThe%20IDENTITY%20Name%20must%20be%20%E2%80%98Managed%20Service%20Identity%E2%80%99%20for%20Polybase%20to%20connect%20to%20the%20Secured%20Storage%20Account.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECREATE%20DATABASE%20SCOPED%20CREDENTIAL%20msi_cred%20WITH%20IDENTITY%20%3D%20'Managed%20Service%20Identity'%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CEM%3EIn%20the%20example%20we%20use%20msi_cred%2C%20feel%20free%20to%20name%20it%20according%20to%20your%20requirements%2C%20note%20that%20it%20must%20be%20used%20when%20creating%20your%20External%20Data%20Source.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EStep%204%20%E2%80%93%20Create%20the%20External%20Data%20Source%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20only%20change%20which%20has%20been%20introduced%20in%20the%20External%20Data%20source%20creation%20is%20the%20change%20to%20the%20new%20schema%20and%20the%20updated%20endpoint.%3C%2FP%3E%0A%3CP%3EWhen%20creating%20your%20External%20data%20source%20ensure%20that%20you%20use%20ABFSS%20and%20NOT%20WASBS%20and%20that%20your%20location%20points%20to%20dfs.core.windows.net.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECREATE%20EXTERNAL%20DATA%20SOURCE%20ext_datasource_with_abfss%3C%2FP%3E%0A%3CP%3EWITH%20(TYPE%20%3D%20hadoop%2C%3C%2FP%3E%0A%3CP%3ELOCATION%20%3D%20'abfss%3A%2F%2Fcontainer%40mystorageaccount.dfs.core.windows.net'%2C%3C%2FP%3E%0A%3CP%3ECREDENTIAL%20%3D%20msi_cred)%3B%20--the%20credential%20name%20we%20created%20in%20the%20previous%20step%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAdditional%20Info%20on%20External%20Data%20Sources%20can%20be%20found%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Ft-sql%2Fstatements%2Fcreate-external-data-source-transact-sql%3Fview%3Dazure-sqldw-latest%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EStep%205%20%E2%80%93%20Create%20the%20External%20file%20format%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%26nbsp%3B%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EWhen%20connecting%20to%20files%20stored%20on%20an%20external%20location%20we%20need%20to%20specify%20what%20the%20file%20looks%20like%20in%20the%20terms%20of%20row%20%2F%20column%20delimiters%2C%20specific%20date%20time%20formats%20I%20would%20require%20to%20persist%20and%20what%20type%20of%20file%20the%20source%20file%20is.%26nbsp%3B%20Additional%20Info%20on%20this%20can%20be%20found%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Ft-sql%2Fstatements%2Fcreate-external-file-format-transact-sql%3Fview%3Dsql-server-2017%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20the%20example%20I%20will%20create%20a%20file%20format%20that%20references%20a%20Delimited%20Text%20file%20which%20is%20comma%20delimited%20and%20has%20no%20table%20header%20in%20the%20file.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECREATE%20EXTERNAL%20FILE%20FORMAT%20NoHeader_CSV%3C%2FP%3E%0A%3CP%3EWITH%20(FORMAT_TYPE%20%3D%20DELIMITEDTEXT%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20FORMAT_OPTIONS%20(%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20FIELD_TERMINATOR%20%3D%20'%2C'%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20STRING_DELIMITER%20%3D%20'%22'%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20USE_TYPE_DEFAULT%20%3D%20True)%3C%2FP%3E%0A%3CP%3E)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EStep%206%20%E2%80%93%20Create%20External%20Table%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%26nbsp%3B%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EThe%20final%20step%20is%20to%20create%20the%20external%20table%20which%20will%20be%20consuming%20the%20credentials%20we%E2%80%99ve%20created%20and%20connecting%20to%20the%20External%20Data%20Source%20that%20has%20been%20provided.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CEM%3EWhen%20creating%20the%20above-mentioned%20components%20in%20the%20Data%20Warehouse%20we%20are%20only%20parsing%20the%20Syntax%20and%20if%20the%20syntax%20is%20valid%20the%20object%20will%20create.%20Therefore%2C%20you%20will%20only%20know%20that%20there%20is%20a%20problem%20once%20you%20create%20your%20External%20Table%20as%20only%20then%20will%20we%20authenticate%20using%20the%20information%20that%20has%20been%20provided.%20%3C%2FEM%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECREATE%20EXTERNAL%20TABLE%20%3CYOURTABLENAME%3E%3C%2FYOURTABLENAME%3E%3C%2FP%3E%0A%3CP%3E(%3C%2FP%3E%0A%3CP%3EColumn1%20varchar(50)%20Null%2C%3C%2FP%3E%0A%3CP%3EColumn2%20IDENTITY%2C%3C%2FP%3E%0A%3CP%3EColumn3%20datetime2%2C%3C%2FP%3E%0A%3CP%3E...%3C%2FP%3E%0A%3CP%3E)%3C%2FP%3E%0A%3CP%3EWITH%3C%2FP%3E%0A%3CP%3E(%3C%2FP%3E%0A%3CP%3ELOCATION%20%3D%20'%2Fpath%2Ffilename'%2C--Path%20will%20be%20the%20root%20of%20the%20specified%20container%3C%2FP%3E%0A%3CP%3EDATA_SOURCE%20%3D%20ext_datasource_with_abfss%20%2C%3C%2FP%3E%0A%3CP%3EFILE_FORMAT%20%3D%20NoHeader_CSV%3C%2FP%3E%0A%3CP%3E)%20%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20followed%20the%20instructions%20and%20guidelines%20provided%20and%20specified%20a%20valid%20path%20and%20file%20name%2C%20you%20will%20be%20able%20to%20Create%20the%20External%20Table%20successfully%20and%20Select%20from%20the%20object%20without%20failure.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CU%3E%3CSTRONG%3ESolution%20Overview%3C%2FSTRONG%3E%3C%2FU%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20new%20ABFSS%20Schema%20is%20a%20secured%20schema%20which%20encrypts%20all%20communication%20between%20the%20storage%20account%20and%20Azure%20Data%20Warehouse.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20Managed%20Service%20Identity%20allows%20you%20to%20create%20a%20more%20secure%20credential%20which%20is%20bound%20to%20the%20Logical%20Server%20and%20therefore%20no%20longer%20requires%20user%20details%20or%20storage%20keys%20to%20be%20shared%20for%20credentials%20to%20be%20created.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20Storage%20account%20security%20is%20streamlined%20and%20we%20now%20grant%20RBAC%20permissions%20to%20the%20Managed%20Service%20Identity%20for%20the%20Logical%20Server%20with%20no%20requirement%20to%20grant%20User%20Specific%20access%20to%20the%20Storage%20account.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20solution%20allows%20for%20the%20Storage%20account%20firewall%20to%20be%20enabled%20which%20limits%20IP%20addresses%20which%20are%20allowed%20to%20connect%20to%20the%20storage%20endpoint%20and%20adhere%20to%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FAzure-Data-Warehouse-Support%2FAzure-Data-Warehouse-Security-Best-Practice-Guidelines-and%2Fba-p%2F722768%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3Esecurity%20best%20practices%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20are%20unable%20to%20complete%20the%20steps%20in%20the%20article%2C%20please%20do%20reach%20out%20to%20us%20by%20logging%20a%20Support%20Request.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EPart%202%20-%20Unsecured%20storage%20the%20original%20Polybase%20configuration%3C%2FSTRONG%3Eto%20follow%20soon.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-740376%22%20slang%3D%22en-US%22%3E%3CP%3EPart%201%20of%20the%20series%20addresses%20secured%20storage%20account%20configuration%2C%20what%20is%20required%20and%20what%20changes%20have%20been%20made%20to%20make%20this%20possible.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-740376%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EData%20Import%20and%20Export%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPolyBase%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

Customers are ever increasingly making use of Polybase to load data into the Azure Data Warehouse, Polybase is the go-to solution when attempting load large files and thousands to millions of records. The intention of this Guide is not explain what Polybase is and how it works if you require a deeper understanding of how it works or looking for more granular information on Polybase start here

 

The intention of this guide is to help you decide which Polybase configuration will fulfill your requirements. It will be a multi part guide and in each part of the guide I will review the credentials, the requirements and provide the examples and relevant articles which will make your implementation of Polybase hassle free.

 

In Part 2 we will review Unrestricted storage and the original Polybase configuration

In Part 3 we will review Integration tools which make use of Polybase to load data (ADF/Databricks)

In Part 4 we will review how to modify your existing Polybase configuration without recreation

 

Part 1 – Secured Storage Account

 

In Part 1 we will focus on the most sought-after feature within Polybase, Connecting to a Secured storage account. The ability to connect to a secured storage account was generally available December 2018 and has since caused much confusion due to the specific requirements to make this possible, none of which are difficult to implement and will require a once off configuration.

If you have a Secured storage account or want to secure your storage account and would like to make use of Polybase to load or read your external data the following steps are required, there is no other alternative or workaround. We went through extensive development and released multiple components to make this possible.

 

Requirements

 

There are 2 requirements which make this configuration possible

  • Generation 2 Storage account, if you do not have a Generation 2 storage account this will not be possible, upgrade to Gen2 before going further following this guide
  • VNET Service Endpoints with Azure storage which is what I will be covering in this guide and is available for further reference here

 

Implementation

 

The Polybase engineering team released a new credential called Managed Service Identity as well as a new secure schema ABFSS which connects to an updated endpoint dfs.core.windows.net.

Using these 3 components it is now possible for you to enable the storage firewall and limit access to Azure Services within your storage account. Polybase source connections from the Azure Data Warehouse do not fall with the standard Azure Service IP boundaries which is why this was previously not possible.  

(The same configuration is applicable to Blob Store and Data Lake there is no difference in the configuration)

 

Database Security Consideration

 

Before we proceed further, we need to address the permissions a user requires to create all the required objects. To make this easier and more manageable I would suggest creating a role within your Data Warehouse and making users role members which would avoid having to grant and revoke permissions individually as users are added or removed.  The permissions which are required are elevated and therefore I would advise that only Database Administrators, Senior Project Members or knowledgeable users are granted these permissions.

Below is all the permissions you will require within the database, the script will create the roll, assign the permissions to the role and add the role membership to the designed user account. Specify required Data Warehouse DB name and User account.

 

Create Role Polybase_Users 

Grant CREATE TABLE TO Polybase_Users

Grant ALTER ANY SCHEMA TO Polybase_Users

Grant ALTER ANY EXTERNAL DATA SOURCE TO Polybase_Users

Grant ALTER ANY EXTERNAL FILE FORMAT TO Polybase_Users

Grant CONTROL ON DATABASE::[] TO Polybase_Users

sp_addrolemember Polybase_Users , <yourUsername>

 

Step1 – Create the MSI

 

Register the Logical Database Server which hosts your Azure Data Warehouse within Azure Active directory, the identity will be used to authenticate with the storage account and grant you access to your external data

 

In order to so run the following Powershell commands, you can run this from the Azure Module if you have it installed or run the command from the Azure Portal using Cloudshell.

 

Connect-AzAccount

Select-AzSubscription -SubscriptionId <your-subscriptionId>

Set-AzSqlServer -ResourceGroupName <your-database-server-resourceGroup> -ServerName <your-database-servername> -AssignIdentity

 

 (Note: You do not have to specify database.windows.net only the server name is required. Details provided on the Server Overview Pane)

P1DWInfo.png

 

Step2 – Grant the permissions

 

With the identity created you will now be able to grant the Identity access to the target storage account which I want to secure with a firewall.  

 

To grant these permissions, the grantor must be a member of a group or role which has Owner Privileges. If you do not have such permissions, you would not be able to grant the Server MSI the required role.

 

  • Within the storage account navigate to Access Control(IAM)
  • Select Add a Role Assignment

ra.PNG

 

  • Select Storage Blob Data Contributor from the Role Dropdown list
  • Search for your <SERVER NAME> in the Select Search box 

ara.PNG

  • Once you have found the server name save the configuration, so permissions are applied.

The permissions have now been granted at a storage level to the Managed Service Identity, this will allow you to connect to the storage account.

 

Step 3 – Database Credential Configuration

 

The next step is to configure the database credentials which will be used by your External Data Source

If you have never created any external objects and this is the first time you are configuring Polybase you have to start out by creating a Master Key within your database. (Azure Data Warehouse does not require a password to be specified for the Master Key. If you make use of a password, take record of the password)

 

CREATE MASTER KEY [ENCRYPTION BY PASSWORD = 'somepassword'];

 

Once the key is created proceed with creating the credentials which will refer to the Managed Service Identity. It does not require you to specify a SECRET when you use the Managed Service Identity.

The IDENTITY Name must be ‘Managed Service Identity’ for Polybase to connect to the Secured Storage Account.

 

CREATE DATABASE SCOPED CREDENTIAL msi_cred WITH IDENTITY = 'Managed Service Identity';

 

In the example we use msi_cred, feel free to name it according to your requirements, note that it must be used when creating your External Data Source.

 

Step 4 – Create the External Data Source

 

The only change which has been introduced in the External Data source creation is the change to the new schema and the updated endpoint.

When creating your External data source ensure that you use ABFSS and NOT WASBS and that your location points to dfs.core.windows.net. 

 

CREATE EXTERNAL DATA SOURCE ext_datasource_with_abfss

WITH (TYPE = hadoop,

LOCATION = 'abfss://container@mystorageaccount.dfs.core.windows.net',

CREDENTIAL = msi_cred); --the credential name we created in the previous step

 

Additional Info on External Data Sources can be found here

 

Step 5 – Create the External file format

 

When connecting to files stored on an external location we need to specify what the file looks like in the terms of row / column delimiters, specific date time formats I would require to persist and what type of file the source file is.  Additional Info on this can be found here

 

In the example I will create a file format that references a Delimited Text file which is comma delimited and has no table header in the file.

 

CREATE EXTERNAL FILE FORMAT NoHeader_CSV

WITH (FORMAT_TYPE = DELIMITEDTEXT,

      FORMAT_OPTIONS (

          FIELD_TERMINATOR = ',',

          STRING_DELIMITER = '"',

          USE_TYPE_DEFAULT = True)

)

 

 

Step 6 – Create External Table

 

The final step is to create the external table which will be consuming the credentials we’ve created and connecting to the External Data Source that has been provided.

 

When creating the above-mentioned components in the Data Warehouse we are only parsing the Syntax and if the syntax is valid the object will create. Therefore, you will only know that there is a problem once you create your External Table as only then will we authenticate using the information that has been provided.

 

CREATE EXTERNAL TABLE <YourTableName>

(

Column1 varchar(50) Null,

Column2 IDENTITY,

Column3 datetime2,

...

)

WITH

(

LOCATION = '/path/filename',--Path will be the root of the specified container

DATA_SOURCE = ext_datasource_with_abfss ,

FILE_FORMAT = NoHeader_CSV

) ;

 

If you followed the instructions and guidelines provided and specified a valid path and file name, you will be able to Create the External Table successfully and Select from the object without failure.  

 

Solution Overview

 

The new ABFSS Schema is a secured schema which encrypts all communication between the storage account and Azure Data Warehouse. 

The Managed Service Identity allows you to create a more secure credential which is bound to the Logical Server and therefore no longer requires user details or storage keys to be shared for credentials to be created. 

The Storage account security is streamlined and we now grant RBAC permissions to the Managed Service Identity for the Logical Server with no requirement to grant User Specific access to the Storage account. 

The solution allows for the Storage account firewall to be enabled which limits IP addresses which are allowed to connect to the storage endpoint and adhere to security best practices 

 

 

If you are unable to complete the steps in the article, please do reach out to us by logging a Support Request.

 

Part 2 - Unsecured storage the original Polybase configuration to follow soon.