Skip to content

Commit 838768a

Browse files
authored
add Azure Resource Manager service doc (#467)
1 parent ab825f6 commit 838768a

2 files changed

Lines changed: 266 additions & 11 deletions

File tree

Lines changed: 266 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,266 @@
1+
---
2+
title: "Resource Manager"
3+
description: Get started with Azure Resource Manager on LocalStack
4+
template: doc
5+
---
6+
7+
import AzureFeatureCoverage from "../../../../components/feature-coverage/AzureFeatureCoverage";
8+
9+
## Introduction
10+
11+
Azure Resource Manager (ARM) is the unified deployment and management layer for Azure resources, providing a consistent control-plane API for resource organization and lifecycle management. It enables idempotent, declarative infrastructure as code (IaC) through JSON-based ARM templates and Bicep modules, allowing for automated resource group orchestration and provider registrations.
12+
13+
For more information, see:
14+
- [[What is Azure Resource Manager?](https://learn.microsoft.com/azure/azure-resource-manager/management/overview)](https://learn.microsoft.com/azure/azure-resource-manager/management/overview)
15+
- [[What are ARM templates?](https://learn.microsoft.com/azure/azure-resource-manager/templates/overview)](https://learn.microsoft.com/azure/azure-resource-manager/templates/overview)
16+
- [[What is Bicep?](https://learn.microsoft.com/azure/azure-resource-manager/bicep/overview)](https://learn.microsoft.com/azure/azure-resource-manager/bicep/overview)
17+
18+
LocalStack for Azure enables seamless interaction with the emulator’s management REST API via Azure Resource Manager. It also provides native support for Bicep and ARM templates, allowing for standardized Infrastructure as Code (IaC) deployments within your local environment.
19+
The supported APIs are available on our [API Coverage section](#api-coverage), which provides information on the extent of Resource Manager's integration with LocalStack.
20+
21+
## Getting started
22+
23+
This guide is designed for users new to Resource Manager and assumes basic knowledge of the Azure CLI and our `azlocal` wrapper script.
24+
25+
Launch LocalStack using your preferred method. For more information, see [Introduction to LocalStack for Azure](/azure/getting-started/). Once the container is running, enable Azure CLI interception by running:
26+
27+
```bash
28+
azlocal start-interception
29+
```
30+
31+
This command points the `az` CLI away from the public Azure management REST API and toward the LocalStack for Azure emulator API.
32+
To revert this configuration, run:
33+
34+
```bash
35+
azlocal stop-interception
36+
```
37+
38+
This reconfigures the `az` CLI to send commands to the official Azure management REST API.
39+
40+
### Create a resource group
41+
42+
Create a resource group:
43+
44+
```bash
45+
az group create \
46+
--name rg-resources-demo \
47+
--location westeurope
48+
```
49+
50+
```bash title="Output"
51+
{
52+
"name": "rg-resources-demo",
53+
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-resources-demo",
54+
"location": "westeurope",
55+
"properties": {
56+
"provisioningState": "Succeeded"
57+
},
58+
"..."
59+
}
60+
```
61+
62+
### Get and list resource groups
63+
64+
Get the resource group details:
65+
66+
```bash
67+
az group show --name rg-resources-demo
68+
```
69+
70+
```bash title="Output"
71+
{
72+
"name": "rg-resources-demo",
73+
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-resources-demo",
74+
"location": "westeurope",
75+
"properties": {
76+
"provisioningState": "Succeeded"
77+
},
78+
"..."
79+
}
80+
```
81+
82+
List matching resource groups:
83+
84+
```bash
85+
az group list --query "[?name=='rg-resources-demo']"
86+
```
87+
88+
```bash title="Output"
89+
[
90+
{
91+
"name": "rg-resources-demo",
92+
"location": "westeurope",
93+
"..."
94+
}
95+
]
96+
```
97+
98+
### Query resource providers
99+
100+
Get a specific provider:
101+
102+
```bash
103+
az provider show --namespace Microsoft.Resources
104+
```
105+
106+
```bash title="Output"
107+
{
108+
"namespace": "Microsoft.Resources",
109+
"registrationState": "Registered",
110+
"registrationPolicy": "RegistrationFree",
111+
"resourceTypes": [
112+
{
113+
"resourceType": "resourceGroups",
114+
"apiVersions": ["2023-07-01", "..."],
115+
"..."
116+
}
117+
...
118+
],
119+
"..."
120+
}
121+
```
122+
123+
List provider registration state:
124+
125+
```bash
126+
az provider list --query "[?namespace=='Microsoft.Resources'].{namespace:namespace,registrationState:registrationState}"
127+
```
128+
129+
```bash title="Output"
130+
[
131+
{
132+
"namespace": "Microsoft.Resources",
133+
"registrationState": "Registered"
134+
}
135+
]
136+
```
137+
138+
### Deploy a Bicep template
139+
140+
Create a Bicep file named `main.bicep` that provisions a storage account inside the resource group:
141+
142+
```bicep
143+
param location string = resourceGroup().location
144+
param storageAccountName string = 'stbicep${uniqueString(resourceGroup().id)}'
145+
146+
resource storageAccount 'Microsoft.Storage/storageAccounts@2023-05-01' = {
147+
name: storageAccountName
148+
location: location
149+
sku: {
150+
name: 'Standard_LRS'
151+
}
152+
kind: 'StorageV2'
153+
}
154+
155+
output storageAccountId string = storageAccount.id
156+
```
157+
158+
Deploy the template into the resource group:
159+
160+
```bash
161+
az deployment group create \
162+
--resource-group rg-resources-demo \
163+
--template-file main.bicep
164+
```
165+
166+
```bash title="Output"
167+
{
168+
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-resources-demo/providers/Microsoft.Resources/deployments/main",
169+
"name": "main",
170+
"properties": {
171+
"correlationId": "...",
172+
"mode": "Incremental",
173+
"provisioningState": "Succeeded",
174+
"outputResources": [
175+
{
176+
...
177+
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-resources-demo/providers/Microsoft.Storage/storageAccounts/..."
178+
}
179+
],
180+
"outputs": {
181+
"storageAccountId": {
182+
"type": "String",
183+
"value": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-resources-demo/providers/Microsoft.Storage/storageAccounts/..."
184+
}
185+
},
186+
"..."
187+
},
188+
"type": "Microsoft.Resources/deployments",
189+
"..."
190+
}
191+
```
192+
193+
Verify the deployment status:
194+
195+
```bash
196+
az deployment group show \
197+
--resource-group rg-resources-demo \
198+
--name main
199+
```
200+
201+
```bash title="Output"
202+
{
203+
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-resources-demo/providers/Microsoft.Resources/deployments/main",
204+
"name": "main",
205+
"properties": {
206+
"correlationId": "...",
207+
"mode": "Incremental",
208+
"provisioningState": "Succeeded",
209+
...
210+
},
211+
"type": "Microsoft.Resources/deployments",
212+
"..."
213+
}
214+
```
215+
216+
## Features
217+
218+
The Resource Manager emulator supports the following features:
219+
220+
- **Resource group lifecycle**: Create, update, get, list, delete, and check existence of resource groups. Deletion cascades to all contained resources.
221+
- **Resource listing and filtering**: List resources across a subscription or within a resource group, with support for `$filter` and `$expand` query parameters.
222+
- **Resource move**: Move top-level resources between resource groups with validation of source and destination groups, resource locks, and resource hierarchy.
223+
- **ARM template deployments**: Create or update deployments at the resource group scope and at the subscription scope. Templates are parsed and resources are provisioned in dependency order.
224+
- **Bicep support**: Bicep files compiled by the Azure CLI are accepted as ARM JSON templates. The emulator handles Bicep 2.0 symbolic names, `languageVersion`, and `definitions` sections.
225+
- **Nested deployments**: Inner-scoped and outer-scoped nested templates (`Microsoft.Resources/deployments`) are supported, including parameter passing between scopes.
226+
- **ARM template functions**: Over 60 built-in functions are evaluated locally, including `resourceId`, `reference`, `listKeys`, `concat`, `format`, `uniqueString`, `resourceGroup`, `subscription`, `copyIndex`, `if`, `union`, `createObject`, and others.
227+
- **Template validation**: Validate ARM templates at the resource group scope and subscription scope without creating resources.
228+
- **Copy loops and conditional resources**: The `copy` element and `condition` property are supported, enabling iterative resource creation and conditional deployment logic.
229+
- **Deployment operations**: List deployment operations at the resource group scope and at the subscription scope, including provisioning state and target resource details.
230+
- **Deployment outputs**: Template outputs are evaluated after deployment completes, with full ARM expression resolution.
231+
- **Subscription management**: List and get subscriptions, and list available Azure locations with metadata.
232+
- **Tenant listing**: List tenant identifiers associated with the emulator environment.
233+
- **Provider registry**: List, get, register, and unregister resource providers, including resource type details, API versions, and zone mappings.
234+
- **Resource group locks**: Lock and unlock resource groups to prevent accidental deletion or modification of contained resources.
235+
236+
## Limitations
237+
238+
- **Single subscription**: The emulator exposes a single subscription. Multiple subscriptions are not supported.
239+
- **Template validation is a no-op**: The `deployments validate` and `deployments validate at subscription scope` endpoints return a success response without performing syntactic or semantic validation.
240+
- **No management group or tenant-scoped deployments**: Deployments are supported only at the resource group and subscription scopes.
241+
- **No what-if analysis**: The `az deployment group what-if` operation is not implemented.
242+
- **ARM template function coverage**: While over 60 functions are supported, some less common functions or advanced overloads may not be fully implemented.
243+
- **No resource tags on generic resource listings**: Tags and extended properties may not be fully populated when listing resources across a subscription.
244+
- **No RBAC enforcement on resource operations**: All API calls succeed without role-based access control checks.
245+
- **Deployment concurrency**: Resources within a single deployment are created sequentially with dependency resolution, not in full parallel as in Azure.
246+
- **No deployment cancellation**: Running deployments cannot be cancelled.
247+
- **No deployment deletion**: Deployments are retained in memory and cannot be explicitly deleted via the API.
248+
249+
## Samples
250+
251+
The following samples demonstrate how to use Azure Resource Manager and Bicep with LocalStack for Azure:
252+
253+
- [Function App and Storage](https://github.com/localstack/localstack-azure-samples/tree/main/samples/function-app-storage-http/dotnet/)
254+
- [Function App and Front Door](https://github.com/localstack/localstack-azure-samples/tree/main/samples/function-app-front-door/python/)
255+
- [Function App and Managed Identities](https://github.com/localstack/localstack-azure-samples/tree/main/samples/function-app-managed-identity/python/)
256+
- [Function App and Service Bus](https://github.com/localstack/localstack-azure-samples/tree/main/samples/function-app-service-bus/dotnet/)
257+
- [Web App and Cosmos DB for MongoDB API](https://github.com/localstack/localstack-azure-samples/tree/main/samples/web-app-cosmosdb-mongodb-api/python/)
258+
- [Web App and Cosmos DB for NoSQL API](https://github.com/localstack/localstack-azure-samples/tree/main/samples/web-app-cosmosdb-nosql-api/python/)
259+
- [Web App and Managed Identities](https://github.com/localstack/localstack-azure-samples/tree/main/samples/web-app-managed-identity/python/)
260+
- [Web App and SQL Database](https://github.com/localstack/localstack-azure-samples/tree/main/samples/web-app-sql-database/python/)
261+
- [ACI and Blob Storage](https://github.com/localstack/localstack-azure-samples/tree/main/samples/aci-blob-storage/python/)
262+
- [Azure Service Bus with Spring Boot](https://github.com/localstack/localstack-azure-samples/tree/main/samples/servicebus/java/)
263+
264+
## API Coverage
265+
266+
<AzureFeatureCoverage service="Microsoft.Resources" client:load />

src/content/docs/azure/services/resources.mdx

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)