Quickstart: Share data using Azure Data Share and Bicep
Learn how to set up a new Azure Data Share from an Azure storage account using Bicep, and start sharing your data with customers and partners outside of your Azure organization. For a list of the supported data stores, see Supported data stores in Azure Data Share.
Bicep is a domain-specific language (DSL) that uses declarative syntax to deploy Azure resources. It provides concise syntax, reliable type safety, and support for code reuse. Bicep offers the best authoring experience for your infrastructure-as-code solutions in Azure.
Prerequisites
If you don't have an Azure subscription, create a free account before you begin.
Review the Bicep file
The Bicep file used in this quickstart is from Azure Quickstart Templates.
@description('Specify a project name that is used to generate resource names.')
param projectName string
@description('Specify the location for the resources.')
param location string = resourceGroup().location
@description('Specify an email address for receiving data share invitations.')
param invitationEmail string
@description('Specify snapshot schedule recurrence.')
@allowed([
'Day'
'Hour'
])
param syncInterval string = 'Day'
@description('Specify snapshot schedule start time.')
param syncTime string = utcNow('yyyy-MM-ddTHH:mm:ssZ')
var storageAccountName = '${projectName}store'
var containerName = '${projectName}container'
var dataShareAccountName = '${projectName}shareaccount'
var dataShareName = '${projectName}share'
var roleAssignmentName = guid(sa.id, storageBlobDataReaderRoleDefinitionId, dataShareAccount.id)
var inviteName = '${dataShareName}invite'
var storageBlobDataReaderRoleDefinitionId = resourceId('Microsoft.Authorization/roleDefinitions', '2a2b9908-6ea1-4ae2-8e65-a410df84e7d1')
resource sa 'Microsoft.Storage/storageAccounts@2021-04-01' = {
name: storageAccountName
location: location
sku: {
name: 'Standard_LRS'
}
kind: 'StorageV2'
properties: {
accessTier: 'Hot'
}
}
resource container 'Microsoft.Storage/storageAccounts/blobServices/containers@2021-04-01' = {
name: '${sa.name}/default/${containerName}'
}
resource dataShareAccount 'Microsoft.DataShare/accounts@2021-08-01' = {
name: dataShareAccountName
location: location
identity: {
type: 'SystemAssigned'
}
properties: {}
}
resource dataShare 'Microsoft.DataShare/accounts/shares@2021-08-01' = {
parent: dataShareAccount
name: dataShareName
properties: {
shareKind: 'CopyBased'
}
}
resource roleAssignment 'Microsoft.Authorization/roleAssignments@2020-04-01-preview' = {
scope: sa
name: roleAssignmentName
properties: {
roleDefinitionId: storageBlobDataReaderRoleDefinitionId
principalId: dataShareAccount.identity.principalId
principalType: 'ServicePrincipal'
}
}
resource dataSet 'Microsoft.DataShare/accounts/shares/dataSets@2021-08-01' = {
parent: dataShare
name: containerName
kind: 'Container'
dependsOn: [ // this is used to delay this resource until the roleAssignment replicates
container
invitation
synchronizationSetting
]
properties: {
subscriptionId: subscription().subscriptionId
resourceGroup: resourceGroup().name
storageAccountName: sa.name
containerName: containerName
}
}
resource invitation 'Microsoft.DataShare/accounts/shares/invitations@2021-08-01' = {
parent: dataShare
name: inviteName
properties: {
targetEmail: invitationEmail
}
}
resource synchronizationSetting 'Microsoft.DataShare/accounts/shares/synchronizationSettings@2021-08-01' = {
parent: dataShare
name: '${dataShareName}_synchronizationSetting'
kind: 'ScheduleBased'
properties: {
recurrenceInterval: syncInterval
synchronizationTime: syncTime
}
}
The following resources are defined in the Bicep file:
- Microsoft.Storage/storageAccounts:
- Microsoft.Storage/storageAccounts/blobServices/containers
- Microsoft.DataShare/accounts
- Microsoft.DataShare/accounts/shares
- Microsoft.Storage/storageAccounts/providers/roleAssignments
- Microsoft.DataShare/accounts/shares/dataSets
- Microsoft.DataShare/accounts/shares/invitations
- Microsoft.DataShare/accounts/shares/synchronizationSettings
Deploy the Bicep file
Save the Bicep file as main.bicep to your local computer.
Deploy the Bicep file using either Azure CLI or Azure PowerShell.
az group create --name exampleRG --location eastus az deployment group create --resource-group exampleRG --template-file main.bicep --parameters projectName=<project-name> invitationEmail=<invitation-email>
Note
Replace <project-name> with a project name. The project name will be used to generate resource names. Replace <invitation-email> with an email address for receiving data share invitations.
When the deployment finishes, you should see a message indicating the deployment succeeded.
Review deployed resources
Use the Azure portal, Azure CLI, or Azure PowerShell to list the deployed resources in the resource group.
az resource list --resource-group exampleRG
Clean up resources
When no longer needed, use the Azure portal, Azure CLI, or Azure PowerShell to delete the resource group and its resources.
az group delete --name exampleRG
Next steps
In this quickstart, you learned how to create an Azure data share and invite recipients. To learn more about how a data consumer can accept and receive a data share, continue to the accept and receive data tutorial.