/logicapp-demo

Primary LanguagePowerShellMIT LicenseMIT

logicapp-demo

Infrastructure as Code - Logic App Solution

0

Getting Started

Deploy the Infrastructure

  1. Create a Resource Group
az group create --location southcentralus --name logicapp-demo
  1. Modify Infrastructure Template Parameters as desired

  2. Deploy Infrastructure Template to Resource Group and create a container.

# Set Variables
$ResourceGroup = "logicapp-demo"
$ContainerName = "customers"

# Deploy ARM Template
az group deployment create --template-file azuredeploy.json `
    --parameters azuredeploy.parameters.json `
    --resource-group $ResourceGroup

# Get Storage Context
$StorageAccount = Get-AzureRmStorageAccount `
    -ResourceGroupName $ResourceGroup
$Keys = Get-AzureRmStorageAccountKey `
    -Name $StorageAccount.StorageAccountName `
    -ResourceGroupName $ResourceGroup
$StorageContext = New-AzureStorageContext `
    -StorageAccountName $StorageAccount.StorageAccountName `
    -StorageAccountKey $Keys[0].Value

# Create Blob Container
New-AzureStorageContainer -Name $ContainerName  `
    -Context $StorageContext `
    -Permission Off
  1. Prepare the Database

Login to the database and run the following TSQL Commands

Ensure you replace your storage account name.

CREATE EXTERNAL DATA SOURCE BlobStorage
WITH (    TYPE = BLOB_STORAGE, 
        LOCATION = 'https://<STORAGE_ACCOUNT>.blob.core.windows.net/customers'
);
GO

--Create the Sample Stored Proc
CREATE PROCEDURE uspImportCustomer   
AS   
BEGIN
    BULK INSERT Customer
    FROM 'import.csv'
    WITH 
    (    
        DATA_SOURCE = 'BlobStorage',
        FORMAT='CSV', 
        CODEPAGE = 65001, --UTF-8 encoding
        FIRSTROW=2,
        ROWTERMINATOR = '0x0a',
        TABLOCK
    )
END
GO

Deploy the Logic App