title: "Get Up and Running with Azure Synapse and Pulumi"
date: 2020-12-04
draft: false
meta_desc: Use infrastructure as code to automate deployment of an Azure Synapse workspace
meta_image: synapse.png
authors:
- mikhail-shilkov
tags:
- azure
---
Azure Synapse is an integrated analytics service that combines enterprise data warehousing of Azure SQL Data Warehouse and Big Data analytics of Apache Spark. Azure Synapse is a managed service well integrated with other Azure services for data ingestion and business analytics.
You could use the Azure portal to get started with Azure Synapse, but it can be hard to define sophisticated infrastructure for your analytics pipeline using the portal alone, and many users need to apply version control to their cloud configurations.
The alternative is to use an [infrastructure as code](/what-is/what-is-infrastructure-as-code/) tool to automate building and deploying cloud resources. This article demonstrates how to provision an Azure Synapse workspace using Pulumi and general-purpose programming languages like Python and C#.
Let's start by introducing the components required to provision a basic Azure Synapse workspace. To follow along with the [Synapse Getting Started Guide](https://docs.microsoft.com/en-us/azure/synapse-analytics/get-started), you need the following key Azure infrastructure components:
- **Resource Group** to contain all other resources.
- **Storage Account** to store input data and analytics artifacts.
- **Azure Synapse Workspace**—a collaboration boundary for cloud-based analytics in Azure.
- **SQL Pool**—a dedicated Synapse SQL pool to run T-SQL based analytics.
- **Spark Pool** to use Apache Spark analytics.
- **IP Filters** and **Role Assignments** for secure access control.
## Infrastructure as Code
Let's walk through the steps to build a workspace with all the components mentioned above. We'll use Pulumi to provision the necessary resources. Feel free to pick the language of your choice that will apply to all code snippets.
You can check out the [full source code](https://github.com/pulumi/examples/tree/master/aws-ts-lambda-thumbnailer) in the Pulumi Examples.
### Resource Group
Let's start by defining a resource group to contain all other resources. Be sure to adjust its name and region to your preferred values.
var resourceGroup = new ResourceGroup("resourceGroup", new ResourceGroupArgs
{
ResourceGroupName = "synapse-rg",
Location = "westus2
});
```
{{% /choosable %}}
{{% choosable language typescript %}}
```typescript
const resourceGroup = new resources.ResourceGroup('resourceGroup', {
resourceGroupName: 'synapse-rg',
location: 'westus2',
});
```
{{% /choosable %}}
### Data Lake Storage Account
Synapse workspace will store data in a data lake storage account. We use a Standard Read-Access Geo-Redundant Storage account (SKU `Standard_RAGRS`) for this purpose. Make sure to change the `accountName` to your own globally unique name.
> Note that we also defined a system-assigned managed identity for the workspace.
### Security Setup
You need to allow access to the workspace with a firewall rule. The following is a blank access rule but feel free to restrict it to your target IP range.
{{% choosable language python %}}
```python
allow_all = synapse.IpFirewallRule("allowAll",
resource_group_name=resource_group.name,
workspace_name=workspace.name,
rule_name="allowAll",
end_ip_address="255.255.255.255",
start_ip_address="0.0.0.0")
```
{{% /choosable %}}
{{% choosable language csharp %}}
```csharp
var allowAll = new IpFirewallRule("allowAll", new IpFirewallRuleArgs
{
ResourceGroupName = resourceGroup.Name,
WorkspaceName = workspace.Name,
RuleName = "allowAll",
EndIpAddress = "255.255.255.255",
StartIpAddress = "0.0.0.0"
});
```
{{% /choosable %}}
{{% choosable language typescript %}}
```typescript
new synapse.IpFirewallRule("allowAll", {
resourceGroupName: resourceGroup.name,
workspaceName: workspace.name,
ruleName: "allowAll",
endIpAddress: "255.255.255.255",
startIpAddress: "0.0.0.0",
});
```
{{% /choosable %}}
The following snippet assigns the **Storage Blob Data Contributor** role to the workspace managed identity and your target user. If you use the Azure CLI, run `az ad signed-in-user show --query=objectId` to look up your user ID.
You can now navigate to the [Azure Synapse Quickstart, Step 2](https://docs.microsoft.com/en-us/azure/synapse-analytics/get-started-analyze-sql-pool), and follow along with the data analysis tutorial.
## Conclusion
Azure Synapse is a managed analytics service that accelerates time to insight across data warehouses and big data workloads. A Synapse workspace is a critical component of your cloud infrastructure that you should provision with infrastructure as code and other management best practices.
Pulumi and the native Azure provider open up full access to all types of Azure resources using your favorite programming languages, including Python, C#, and TypeScript. Navigate to the complete Azure Synapse example in [Python](https://github.com/pulumi/examples/tree/master/azure-py-synapse), [C#](https://github.com/pulumi/examples/tree/master/azure-cs-synapse), or [TypeScript](https://github.com/pulumi/examples/tree/master/azure-ts-synapse) and get started today.