Skip to content

Commit 60e1d75

Browse files
authored
Merge pull request #306567 from fauhse/bicep
Adding a bicep template quickstart
2 parents 45955f2 + 1e1f79b commit 60e1d75

2 files changed

Lines changed: 158 additions & 2 deletions

File tree

articles/storage-discovery/TOC.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ items:
1818
items:
1919
- name: Deploy
2020
items:
21-
- name: Create Storage Discovery Workspace
21+
- name: Create a Storage Discovery workspace
2222
href: create-workspace.md
23+
- name: Bicep template for creating a workspace
24+
href: create-workspace-bicep.md
2325
- name: Explore insights
2426
items:
25-
- name: Get Started on Storage Discovery Reports
27+
- name: Get Started on Storage Discovery reports
2628
href: get-started-reports.md
2729
- name: Resources
2830
items:
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
---
2+
title: Bicep template for creating an Azure Storage Discovery workspace
3+
titleSuffix: Azure Storage Discovery
4+
description: Learn how to create an Azure Storage Discovery workspace using a bicep template.
5+
author: fauhse
6+
ms.service: azure-storage-discovery
7+
ms.topic: quickstart-bicep
8+
ms.custom: subject-bicepqs
9+
ms.date: 10/06/2025
10+
ms.author: fauhse
11+
---
12+
13+
# Quickstart: Create a Storage Discovery workspace with a Bicep template
14+
15+
This quickstart shows you how to use a Bicep file to deploy a Storage Discovery workspace in Azure.
16+
17+
[Bicep](../azure-resource-manager/bicep/overview.md) 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.
18+
19+
## Prerequisites
20+
21+
- If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/pricing/purchase-options/azure-account?cid=msft_learn) before you begin.
22+
23+
## Review the Bicep file
24+
25+
The Bicep file used in this quickstart is from [Azure Quickstart Templates](/azure/templates/microsoft.storagediscovery/storagediscoveryworkspaces?pivots=deployment-language-bicep).
26+
27+
```Bicep
28+
@description('Storage Discovery Workspace name')
29+
param workspaceName string
30+
31+
@description('Storage Discovery Workspace location')
32+
param workspaceLocation string = resourceGroup().location
33+
34+
@description('Storage Discovery Workspace SKU')
35+
param workspaceSku string
36+
37+
@description('Storage Discovery Workspace description')
38+
param workspaceDescription string = ''
39+
40+
@description('Storage Discovery Workspace roots')
41+
param workspaceRoots array = []
42+
43+
@description('Storage Discovery Workspace scopes')
44+
param workspaceScopes array = []
45+
46+
@description('Storage Discovery Workspace tags')
47+
param tags object
48+
49+
resource storageDiscoveryResource 'Microsoft.StorageDiscovery/storageDiscoveryWorkspaces@2025-09-01' = {
50+
name: workspaceName
51+
location: workspaceLocation
52+
properties: {
53+
sku: workspaceSku
54+
workspaceRoots: workspaceRoots
55+
description: workspaceDescription
56+
scopes: workspaceScopes
57+
}
58+
tags: (empty(tags) ? {} : tags)
59+
}
60+
```
61+
62+
## Parameters
63+
64+
The template lists [Discovery workspace properties](/azure/templates/microsoft.storagediscovery/storagediscoveryworkspaces?pivots=deployment-language-bicep) that require extra objects:
65+
66+
| Name | Description |
67+
|------------------|-------------|
68+
|`workspaceRoots` | The workspace root designates the storage resources to get insights for. This `string[]` can contain subscription URIs, resource group URIs, or individual storage account resource URIs. You may mix and match these resource types in the array. The identity under which you deploy this template [must have permissions](deployment-planning.md#permissions-to-your-storage-resources) to all resources you list at the time of deployment. Alternatively, you may also provide a single tenant URI in this array. All storage resources under the tenant are then covered by this workspace. When choosing this option, you must not provide any other resource URIs. |
69+
|`scopes` | You can create several scopes in a workspace. A scope allows you to filter the storage resources the workspace covers and obtain different reports for each of these scopes. Filtering is based on ARM resource tags on your storage resources. This property expects a `JSON` object containing sections for `tag key name` : `value` combinations or `tag key names` only. When your storage resources have matching ARM resource tags, they're included in this scope.|
70+
71+
Here's an example of the `JSON` structure defining a single scope in a Discovery workspace.
72+
Storage resources are included in this scope when they have both ARM resource tags:
73+
74+
- The tag key `Department` or `department` with case-matching value `Marketing`.
75+
- The tag key `App` or `app`, regardless of its value.
76+
77+
```json
78+
"scopes": [
79+
{
80+
81+
"displayName": "Marketing App Resources",
82+
83+
"resourceTypes": [
84+
85+
"Microsoft.Storage/storageAccounts"
86+
87+
],
88+
89+
"tags": {
90+
91+
"Department": "Marketing"
92+
93+
},
94+
95+
"tagsKeyOnly": [
96+
97+
"App"
98+
99+
]
100+
101+
}
102+
```
103+
> [!NOTE]
104+
> In Azure, tag names (keys) are case-insensitive for operations. Tag values are case-sensitive.
105+
106+
## Deploy the Bicep file
107+
108+
1. Save the Bicep file as `main.bicep` to your local computer.
109+
110+
1. Deploy the Bicep file by using either Azure PowerShell or Azure CLI.
111+
112+
### [Azure PowerShell](#tab/powershell)
113+
114+
```azurepowershell
115+
New-AzResourceGroup -Name exampleRG -Location eastus
116+
117+
New-AzResourceGroupDeployment -ResourceGroupName exampleRG -TemplateFile ./main.bicep -adminUsername "<admin-username>"
118+
```
119+
120+
### [Azure CLI](#tab/cli)
121+
122+
```azurecli
123+
az group create --name exampleRG --location eastus
124+
125+
az deployment group create --resource-group exampleRG --template-file main.bicep --parameters adminUsername=<admin-username>
126+
```
127+
128+
---
129+
130+
> [!NOTE]
131+
> Replace `<admin-username>` with a username you can authenticate with.
132+
133+
## Review deployed resources
134+
135+
Use the Azure portal, Azure PowerShell, or Azure CLI to list the deployed resources in the resource group.
136+
137+
### [Azure PowerShell](#tab/powershell)
138+
139+
```azurepowershell-interactive
140+
Get-AzResource -ResourceGroupName exampleRG
141+
```
142+
143+
### [Azure CLI](#tab/cli)
144+
145+
```azurecli-interactive
146+
az resource list --resource-group exampleRG
147+
```
148+
149+
---
150+
151+
## Next steps
152+
153+
> [!div class="nextstepaction"]
154+
> [Explore Storage Discovery reports](get-started-reports.md)

0 commit comments

Comments
 (0)