Home
%3CLINGO-SUB%20id%3D%22lingo-sub-1022220%22%20slang%3D%22en-US%22%3ECopy%20data%20from%20Azure%20Blob%20to%20Azure%20Database%20for%20PostgreSQL%20using%20Azure%20Data%20Factory%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1022220%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdata-factory%2Fintroduction%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Data%20Factory%3C%2FA%3E%20is%20a%20fully%20managed%20data%20integration%20service%20that%20allows%20you%20to%20create%20data-driven%20workflows%20in%20a%20code%20free%20visual%20environment%20in%20Azure%20for%20orchestrating%20and%20automating%20data%20movement%20and%20data%20transformation.%20Azure%20Database%20for%20PostgreSQL%20is%20now%20a%20supported%20sink%20destination%20in%20Azure%20Data%20Factory.%20Azure%20Data%20factory%20can%20be%20leveraged%20for%20secure%20one-time%20data%20movement%20or%20running%20continuous%20data%20pipelines%20which%20loads%20data%20into%20Azure%20Database%20for%20PostgreSQL%20from%20disparate%20data%20sources%20running%20on-premises%2C%20in%20Azure%20or%20other%20cloud%20providers%20for%20analytics%20and%20reporting.%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%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F158129iC3789338C834FDB6%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22adfpg.jpg%22%20title%3D%22adfpg.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20this%20tutorial%2C%20you%20create%20a%20Data%20Factory%20pipeline%20that%20copies%20data%20from%20Azure%20Blob%20Storage%20to%20Azure%20Database%20for%20PostgreSQL.%20The%20configuration%20pattern%20in%20this%20tutorial%20applies%20to%20copying%20from%20a%20file-based%20data%20store%20to%20a%20relational%20data%20store.%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%20style%3D%22width%3A%20898px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F158133iB95A42185A8DBC23%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22adf.jpg%22%20title%3D%22adf.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1443186922%22%20id%3D%22toc-hId--1443186922%22%3EPrerequisites%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20don't%20have%20an%20%3CSTRONG%3EAzure%20subscription%3C%2FSTRONG%3E%2C%20create%20a%20%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Ffree%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Efree%3C%2FA%3E%20account%20before%20you%20begin.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EAzure%20Storage%20account%3C%2FSTRONG%3E.%20You%20use%20the%20blob%20storage%20as%20source%20data%20store.%20If%20you%20do%20not%20have%20an%20Azure%20storage%20account%2C%20see%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fstorage%2Fcommon%2Fstorage-quickstart-create-account%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3ECreate%20a%20storage%20account%3C%2FA%3E%20article%20for%20steps%20to%20create%20one.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EAzure%20Database%20for%20PostgreSQL%3C%2FSTRONG%3E.%20You%20use%20the%20database%20as%20sink%20data%20store.%20If%20you%20do%20not%20have%20an%20Azure%20Database%20for%20PostgreSQL%2C%20see%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fpostgresql%2Fquickstart-create-server-database-portal%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3ECreate%20an%20Azure%20Database%20for%20PostgreSQL%3C%2FA%3E%20article%20for%20steps%20to%20create%20one.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20provision%20the%20prerequisites%20quickly%20using%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2Fazure-quickstart-templates%2Fblob%2Fmaster%2F101-data-factory-v2-blob-to-postgresql-copy%2Fprereqs%2Fprereq.azuredeploy.json%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ethis%20azure-quickstart-template%3C%2FA%3E%20%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fportal.azure.com%2F%23create%2FMicrosoft.Template%2Furi%2Fhttps%253A%252F%252Fraw.githubusercontent.com%252FAzure%252Fazure-quickstart-templates%252Fmaster%252F101-data-factory-v2-blob-to-postgresql-copy%252Fprereqs%252Fprereq.azuredeploy.json%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20%3CIMG%20src%3D%22https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2F1-CONTRIBUTION-GUIDE%2Fimages%2Fdeploytoazure.png%22%20border%3D%220%22%20%2F%3E%20%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOnce%20you%20deploy%20the%20above%20template%2C%20you%20should%20see%20the%20following%20resources%20in%20your%20resource%20group%3A%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%20style%3D%22width%3A%20453px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F158137iE81EF923F3DA87B8%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22resourcesadf.png%22%20title%3D%22resourcesadf.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--752625448%22%20id%3D%22toc-hId--752625448%22%3E%26nbsp%3B%3C%2FH3%3E%0A%3CH2%20id%3D%22toc-hId--763128552%22%20id%3D%22toc-hId--763128552%22%3ECreate%20a%20blob%20and%20a%20PostgreSQL%20table%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENow%2C%20prepare%20your%20Azure%20Blob%20and%20Azure%20Database%20for%20PostgreSQL%20for%20the%20tutorial%20by%20performing%20the%20following%20steps%3A%3C%2FP%3E%0A%3CH5%20id%3D%22toc-hId-628497500%22%20id%3D%22toc-hId-628497500%22%3E%26nbsp%3B%3C%2FH5%3E%0A%3CH3%20id%3D%22toc-hId--1880021541%22%20id%3D%22toc-hId--1880021541%22%3ECreate%20a%20source%20blob%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E1.%20Launch%20Notepad.%20Copy%20the%20following%20text%20and%20save%20it%20as%20employee.txt%20file%20on%20your%20disk.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3EJohn%2C%20Doe%0AJane%2C%20Doe%3C%2FPRE%3E%0A%3CP%3E2.%20Use%20tools%20such%20as%20%3CA%20href%3D%22https%3A%2F%2Fstorageexplorer.com%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Storage%20Explorer%3C%2FA%3E%20to%20create%20a%20container%20named%20%E2%80%9Cadftutorial%E2%80%9D%2C%20and%20to%20upload%20the%20%E2%80%9Cemployee.txt%E2%80%9D%20file%20to%20the%20container%20in%20a%20folder%20named%20%E2%80%9Cinput%E2%80%9D%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%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F158138iB19F176A561C6F86%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22blob.png%22%20title%3D%22blob.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-607491292%22%20id%3D%22toc-hId-607491292%22%3ECreate%20a%20sink%20PostgreSQL%20table%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E1.%26nbsp%3BUse%20the%20following%20SQL%20script%20to%20create%20the%20public.employee%20table%20in%20your%20Azure%20Database%20for%20PostgreSQL%20%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3ECREATE%20TABLE%20public.employee%0A(%0A%20%20%20%20ID%20INT%20NOT%20NULL%20GENERATED%20ALWAYS%20AS%20IDENTITY%2C%0A%20%20%20%20FirstName%20VARCHAR%20NOT%20NULL%2C%0A%20%20%20%20LastName%20VARCHAR%20NOT%20NULL%0A)%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E2.%20Allow%20Azure%20services%20to%20access%20Azure%20Database%20for%20PostgreSQL%20Server.%20Ensure%20that%20Allow%20access%20to%20Azure%20services%20setting%20is%20turned%20ON%20for%20your%20Azure%20Database%20for%20PostgreSQL%20Server%20so%20that%20the%20Data%20Factory%20service%20can%20write%20data%20to%20your%20Azure%20Database%20for%20PostgreSQL%20Server.%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fpostgresql%2Fconcepts-firewall-rules%23connecting-from-azure%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EHere%3C%2FA%3E%20are%20the%20instructions%20to%20verify%20and%20turn%20on%20this%20setting.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EImportant%3A%3C%2FSTRONG%3E%20This%20option%20configures%20the%20firewall%20to%20allow%20all%20connections%20from%20Azure%20including%20connections%20from%20the%20subscriptions%20of%20other%20customers.%20When%20selecting%20this%20option%2C%20make%20sure%20your%20login%20and%20user%20permissions%20limit%20access%20to%20only%20authorized%20users.%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%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F158139i6164A9102859A204%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22allowall.png%22%20title%3D%22allowall.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-596988188%22%20id%3D%22toc-hId-596988188%22%3ECreate%20Azure%20Data%20Factory%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20following%20template%20creates%20a%20data%20factory%20of%20version%202%20with%20a%20pipeline%20that%20copies%20data%20from%20a%20folder%20in%20an%20Azure%20Blob%20Storage%20to%20a%20table%20in%20an%20Azure%20Database%20for%20PostgreSQL.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fportal.azure.com%2F%23create%2FMicrosoft.Template%2Furi%2Fhttps%253A%252F%252Fraw.githubusercontent.com%252FAzure%252Fazure-quickstart-templates%252Fmaster%252F101-data-factory-v2-blob-to-postgresql-copy%252Fazuredeploy.json%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20%3CIMG%20src%3D%22https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2F1-CONTRIBUTION-GUIDE%2Fimages%2Fdeploytoazure.png%22%20border%3D%220%22%20%2F%3E%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOnce%20the%20template%20is%20deployed%20successfully%2C%20you%20can%20monitor%20status%20of%20ADF%20copy%20activity%20by%20running%20the%20following%20commands%20in%20PowerShell%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E1.%20Launch%20Azure%20PowerShell.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E2.%20Download%20%3CA%20href%3D%22https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2F101-data-factory-v2-blob-to-postgresql-copy%2Fscripts%2Frunmonitor.ps1%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Erunmonitor.ps1%3C%2FA%3E%26nbsp%3Bto%20a%20folder%20on%20your%20machine.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3EInvoke-WebRequest%20-Uri%20https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2F101-data-factory-v2-blob-to-postgresql-copy%2Fscripts%2Frunmonitor.ps1%20-OutFile%20runmonitor.ps1%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E3.%20Install%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fazure%2Fazurerm%2Finstall-azurerm-ps%3Fview%3Dazurermps-6.13.0%23install-the-azure-powershell-module%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20PowerShell%20module%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3EInstall-Module%20-Name%20AzureRM%20-AllowClobber%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E4.%20Run%20the%20following%20command%20to%20log%20in%20to%20Azure.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3ELogin-AzureRmAccount%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E5.%20Run%20the%20following%20command%20to%20select%20the%20azure%20subscription%20in%20which%20the%20data%20factory%20exists%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3ESelect-AzureRmSubscription%20-SubscriptionId%20%22%26lt%3BSubscription%20Id%26gt%3B%22%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E6.%20Switch%20to%20the%20folder%20where%20you%20downloaded%20the%20script%20file%20runmonitor.ps1%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E7.%20Run%20the%20following%20command%20to%20monitor%20copy%20activity%20after%20specifying%20the%20names%20of%20your%20Azure%20resource%20group%20and%20the%20data%20factory.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E.%5Crunmonitor.ps1%20-resourceGroupName%20%22%26lt%3Bname%20of%20your%20resource%20group%26gt%3B%22%20-DataFactoryName%20%22%26lt%3Bname%20of%20your%20data%20factory%26gt%3B%22%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20the%20Status%20is%20Failed%2C%20you%20can%20check%20the%20error%20message%20printed%20out.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20the%20Status%20is%20Succeeded%2C%20you%20can%20view%20the%20new%20data%20ingested%20in%20PostgreSQL%20table%3A%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%20style%3D%22width%3A%20358px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F158141i651D0EA6913D38C0%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22pgtable.png%22%20title%3D%22pgtable.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20have%20trouble%20deploying%20the%20ARM%20Template%2C%20please%20let%20us%20know%20by%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2Fazure-quickstart-templates%2Fissues%2Fnew%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eopening%20an%20issue%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFeel%20free%20to%20contribute%20any%20updates%20or%20bug%20fixes%20by%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2Fazure-quickstart-templates%2Fpulls%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ecreating%20a%20pull%20request%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThank%20you!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1022220%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F158128i31317649C1218992%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22adfpg.png%22%20title%3D%22adfpg.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECopy%20data%20from%20Azure%20Blob%20to%20Azure%20Database%20for%20PostgreSQL%20using%20Azure%20Data%20Factory%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1022220%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EADF%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EBlob%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Ecopy%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Epostgresql%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Erelational%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

Azure Data Factory is a fully managed data integration service that allows you to create data-driven workflows in a code free visual environment in Azure for orchestrating and automating data movement and data transformation. Azure Database for PostgreSQL is now a supported sink destination in Azure Data Factory. Azure Data factory can be leveraged for secure one-time data movement or running continuous data pipelines which loads data into Azure Database for PostgreSQL from disparate data sources running on-premises, in Azure or other cloud providers for analytics and reporting.

 

adfpg.jpg

 

In this tutorial, you create a Data Factory pipeline that copies data from Azure Blob Storage to Azure Database for PostgreSQL. The configuration pattern in this tutorial applies to copying from a file-based data store to a relational data store.

 

adf.jpg

Prerequisites

 

If you don't have an Azure subscription, create a free account before you begin.

 

Azure Storage account. You use the blob storage as source data store. If you do not have an Azure storage account, see the Create a storage account article for steps to create one.

 

Azure Database for PostgreSQL. You use the database as sink data store. If you do not have an Azure Database for PostgreSQL, see the Create an Azure Database for PostgreSQL article for steps to create one.

 

You can provision the prerequisites quickly using this azure-quickstart-template :

 

 

Once you deploy the above template, you should see the following resources in your resource group:

 

resourcesadf.png

 

Create a blob and a PostgreSQL table

 

Now, prepare your Azure Blob and Azure Database for PostgreSQL for the tutorial by performing the following steps:

 

Create a source blob

 

1. Launch Notepad. Copy the following text and save it as employee.txt file on your disk.

 

John, Doe
Jane, Doe

2. Use tools such as Azure Storage Explorer to create a container named “adftutorial”, and to upload the “employee.txt” file to the container in a folder named “input”

 

blob.png

 

Create a sink PostgreSQL table

 

1. Use the following SQL script to create the public.employee table in your Azure Database for PostgreSQL :

 

CREATE TABLE public.employee
(
    ID INT NOT NULL GENERATED ALWAYS AS IDENTITY,
    FirstName VARCHAR NOT NULL,
    LastName VARCHAR NOT NULL
)

 

2. Allow Azure services to access Azure Database for PostgreSQL Server. Ensure that Allow access to Azure services setting is turned ON for your Azure Database for PostgreSQL Server so that the Data Factory service can write data to your Azure Database for PostgreSQL Server. Here are the instructions to verify and turn on this setting.

 

Important: This option configures the firewall to allow all connections from Azure including connections from the subscriptions of other customers. When selecting this option, make sure your login and user permissions limit access to only authorized users.

 

allowall.png

 

Create Azure Data Factory

 

The following template creates a data factory of version 2 with a pipeline that copies data from a folder in an Azure Blob Storage to a table in an Azure Database for PostgreSQL.

 

 

Once the template is deployed successfully, you can monitor status of ADF copy activity by running the following commands in PowerShell:

 

1. Launch Azure PowerShell.

 

2. Download runmonitor.ps1 to a folder on your machine.

 

Invoke-WebRequest -Uri https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-data-factory-v2-blob-to-postgresql-copy/scripts/runmonitor.ps1 -OutFile runmonitor.ps1

 

3. Install the Azure PowerShell module

 

Install-Module -Name AzureRM -AllowClobber

 

4. Run the following command to log in to Azure.

 

Login-AzureRmAccount

 

5. Run the following command to select the azure subscription in which the data factory exists:

 

Select-AzureRmSubscription -SubscriptionId "<Subscription Id>"

 

6. Switch to the folder where you downloaded the script file runmonitor.ps1

 

7. Run the following command to monitor copy activity after specifying the names of your Azure resource group and the data factory.

 

.\runmonitor.ps1 -resourceGroupName "<name of your resource group>" -DataFactoryName "<name of your data factory>"

 

If the Status is Failed, you can check the error message printed out.

 

If the Status is Succeeded, you can view the new data ingested in PostgreSQL table:

 

pgtable.png

 

If you have trouble deploying the ARM Template, please let us know by opening an issue.

 

Feel free to contribute any updates or bug fixes by creating a pull request.

 

Thank you!