Skip to content

Commit 2aab78a

Browse files
authored
Merge pull request #178915 from whhender/data-share-ps-guide
Adding PS guide to Data Share tutorials
2 parents 75b5e22 + 7bd38cb commit 2aab78a

File tree

2 files changed

+226
-27
lines changed

2 files changed

+226
-27
lines changed

articles/data-share/share-your-data.md

Lines changed: 102 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ author: jifems
55
ms.author: jife
66
ms.service: data-share
77
ms.topic: tutorial
8-
ms.date: 03/24/2021
8+
ms.date: 11/12/2021
99
---
1010
# Tutorial: Share data using Azure Data Share
1111

@@ -22,13 +22,13 @@ In this tutorial, you'll learn how to:
2222
## Prerequisites
2323

2424
* Azure Subscription: If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/) before you begin.
25-
* Your recipient's Azure login e-mail address (using their e-mail alias won't work).
25+
* Your recipient's Azure e-mail address (using their e-mail alias won't work).
2626
* If the source Azure data store is in a different Azure subscription than the one you will use to create Data Share resource, register the [Microsoft.DataShare resource provider](concepts-roles-permissions.md#resource-provider-registration) in the subscription where the Azure data store is located.
2727

2828
### Share from a storage account
2929

3030
* An Azure Storage account: If you don't already have one, you can create an [Azure Storage account](../storage/common/storage-account-create.md)
31-
* Permission to write to the storage account, which is present in *Microsoft.Storage/storageAccounts/write*. This permission exists in the **Contributor** role.
31+
* Permission to write to the storage account, which is present in *Microsoft.Storage/storageAccounts/write*. This permission exists in the **Storage Blob Data Contributor** role.
3232
* Permission to add role assignment to the storage account, which is present in *Microsoft.Authorization/role assignments/write*. This permission exists in the **Owner** role.
3333

3434

@@ -42,9 +42,9 @@ Below is the list of prerequisites for sharing data from SQL source.
4242
* **Azure Active Directory Admin** of the SQL server
4343
* SQL Server Firewall access. This can be done through the following steps:
4444
1. In Azure portal, navigate to SQL server. Select *Firewalls and virtual networks* from left navigation.
45-
1. Click **Yes** for *Allow Azure services and resources to access this server*.
46-
1. Click **+Add client IP**. Client IP address is subject to change. This process might need to be repeated the next time you are sharing SQL data from Azure portal. You can also add an IP range.
47-
1. Click **Save**.
45+
1. Select **Yes** for *Allow Azure services and resources to access this server*.
46+
1. Select **+Add client IP**. Client IP address is subject to change. This process might need to be repeated the next time you are sharing SQL data from Azure portal. You can also add an IP range.
47+
1. Select **Save**.
4848

4949
#### Prerequisites for sharing from Azure Synapse Analytics (workspace) SQL pool
5050

@@ -59,13 +59,13 @@ Below is the list of prerequisites for sharing data from SQL source.
5959
create user "<share_acct_name>" from external provider;
6060
exec sp_addrolemember db_datareader, "<share_acct_name>";
6161
```
62-
Note that the *<share_acc_name>* is the name of your Data Share resource. If you have not created a Data Share resource as yet, you can come back to this pre-requisite later.
62+
The *<share_acc_name>* is the name of your Data Share resource. If you have not created a Data Share resource as yet, you can come back to this pre-requisite later.
6363

6464
* Synapse workspace Firewall access. This can be done through the following steps:
6565
1. In Azure portal, navigate to Synapse workspace. Select *Firewalls* from left navigation.
66-
1. Click **ON** for *Allow Azure services and resources to access this workspace*.
67-
1. Click **+Add client IP**. Client IP address is subject to change. This process might need to be repeated the next time you are sharing SQL data from Azure portal. You can also add an IP range.
68-
1. Click **Save**.
66+
1. Select **ON** for *Allow Azure services and resources to access this workspace*.
67+
1. Select **+Add client IP**. Client IP address is subject to change. This process might need to be repeated the next time you are sharing SQL data from Azure portal. You can also add an IP range.
68+
1. Select **Save**.
6969

7070

7171
### Share from Azure Data Explorer
@@ -142,6 +142,48 @@ Use these commands to create the resource:
142142
az datashare account list --resource-group testresourcegroup
143143
```
144144

145+
### [PowerShell](#tab/powershell)
146+
147+
Create an Azure Data Share resource in an Azure resource group.
148+
149+
Start by preparing your environment for PowerShell. You can either run PowerShell commands locally or using the Bash environment in the Azure Cloud Shell.
150+
151+
[!INCLUDE [azure-powershell-requirements-no-header.md](../../includes/azure-powershell-requirements-no-header.md)]
152+
153+
[![Launch Cloud Shell in a new window](../../includes/media/cloud-shell-try-it/hdi-launch-cloud-shell.png)](https://shell.azure.com)
154+
155+
Use these commands to create the resource:
156+
157+
1. Use the [Connect-AzAccount](/powershell/module/az.accounts/connect-azaccount) command to connect to your Azure account.
158+
159+
```azurepowershell
160+
Connect-AzAccount
161+
```
162+
163+
1. Run the [Set-AzContext](/powershell/module/az.accounts/set-azcontext) command to set the correct subscription, if you have multiple subscriptions.
164+
165+
```azurepowershell
166+
Set-AzContext [SubscriptionID/SubscriptionName]
167+
```
168+
169+
1. Run the [New-AzResourceGroup](/powershell/module/az.resources/new-azresourcegroup) command to create a resource group, or use an existing resource group:
170+
171+
```azurepowershell
172+
New-AzResourceGroup -Name <String> -Location <String>
173+
```
174+
175+
1. Run the [New-AzDataShare](/powershell/module/az.datashare/new-azdatashareaccount) command to create a Data Share account:
176+
177+
```azurepowershell
178+
New-AzDataShareAccount -ResourceGroupName <String> -Name <String> -Location <String>
179+
```
180+
181+
Run the [Get-AzDataShareAccount](/powershell/module/az.datashare/get-azdatashareaccount) command to see your Data Share accounts:
182+
183+
```azurecli
184+
Get-AzDataShareAccount
185+
```
186+
145187
---
146188

147189
## Create a share
@@ -192,13 +234,13 @@ Use these commands to create the resource:
192234

193235
### [Azure CLI](#tab/azure-cli)
194236

195-
1. Run the [az storage account create](/cli/azure/storage/account#az_storage_account_create) command to create a Data Share:
237+
1. Run the [az storage account create](/cli/azure/storage/account#az_storage_account_create) command to create a Storage account for this Data Share:
196238

197239
```azurecli
198240
az storage account create --resource-group testresourcegroup --name ContosoMarketplaceAccount
199241
```
200242

201-
1. Use the [az storage container create](/cli/azure/storage/container#az_storage_container_create) command to create a container for the share in the previous command:
243+
1. Use the [az storage container create](/cli/azure/storage/container#az_storage_container_create) command to create a container inside the storage account created in the previous command:
202244

203245
```azurecli
204246
az storage container create --name ContosoMarketplaceContainer --account-name ContosoMarketplaceAccount
@@ -220,6 +262,53 @@ Use these commands to create the resource:
220262
--account-name ContosoMarketplaceAccount --target-email "jacob@fabrikam"
221263
```
222264

265+
### [PowerShell](#tab/powershell)
266+
267+
1. If you do not already have data you would like to share, you can follow these steps to create a storage account. If you already have storage, you may skip to step 2.
268+
269+
1. Run the [New-AzStorageAccount](/powershell/module/az.storage/new-azstorageaccount) command to create an Azure Storage account:
270+
271+
```azurepowershell
272+
$storageAccount = New-AzStorageAccount -ResourceGroupName <String> -AccountName <String> -Location <String> -SkuName <String>
273+
274+
$ctx = $storageAccount.Context
275+
```
276+
277+
1. Run the [New-AzStorageContainer](/powershell/module/az.storage/new-azstoragecontainer) command to create a container in your new Azure Storage account that will hold your data:
278+
279+
```azurepowershell
280+
$containerName = <String>
281+
282+
New-AzStorageContainer -Name $containerName -Context $ctx -Permission blob
283+
```
284+
285+
1. Run the [Set-AzStorageBlobContent](/powershell/module/az.storage/new-azstoragecontainer) command to upload a file. The follow example uploads _textfile.csv_ from the _D:\testFiles_ folder on local memory, to the container you created.
286+
287+
```azurepowershell
288+
Set-AzStorageBlobContent -File "D:\testFiles\textfile.csv" -Container $containerName -Blob "textfile.csv" -Context $ctx
289+
```
290+
291+
For more information about working with Azure Storage in PowerShell, follow this [Azure Storage PowerShell guide](../storage/blobs/storage-quickstart-blobs-powershell.md).
292+
293+
294+
1. Run the [New-AzDataShare](/powershell/module/az.datashare/new-azdatashare) command to create your Data Share:
295+
296+
```azurepowershell
297+
New-AzDataShare -ResourceGroupName <String> -AccountName <String> -Name <String> -ShareKind "CopyBased" -Description <String> -TermsOfUse <String>
298+
```
299+
300+
1. Use the [New-AzDataShareInvitation](/powershell/module/az.datashare/get-azdatasharereceivedinvitation) command to create the invitation for the specified address:
301+
302+
```azurepowershell
303+
New-AzDataShareInvitation -ResourceGroupName <String> -AccountName <String> -ShareName <String> -Name <String> -TargetEmail <String>
304+
```
305+
306+
1. Use the [New-AzDataShareSynchronizationSetting](/powershell/module/az.datashare/new-azdatasharesynchronizationsetting) command to set a synchronization recurrence for your share. This can be daily, hourly, or at a particular time.
307+
308+
```azurepowershell
309+
New-AzDataShareSynchronizationSetting -ResourceGroupName <String> -AccountName <String> -ShareName <String> -Name <String> -RecurrenceInterval <String> -SynchronizationTime <DateTime>
310+
```
311+
223312
---
224313

225314
Your Azure Data Share has now been created and the recipient of your Data Share is now ready to accept your invitation.
@@ -230,7 +319,7 @@ When the resource is no longer needed, go to the **Data Share Overview** page an
230319

231320
## Next steps
232321

233-
In this tutorial, you learnt how to create an Azure Data Share and invite recipients. To learn about how a Data Consumer can accept and receive a data share, continue to the accept and receive data tutorial.
322+
In this tutorial, you learned how to create an Azure Data Share and invite recipients. To learn about how a Data Consumer can accept and receive a data share, continue to the accept and receive data tutorial.
234323

235324
> [!div class="nextstepaction"]
236325
> [Tutorial: Accept and receive data using Azure Data Share](subscribe-to-data-share.md)

0 commit comments

Comments
 (0)