Skip to content

Commit f96fa24

Browse files
authored
[Hub apps] Create the hub-storage module for storage setup (#1492)
1 parent b773797 commit f96fa24

File tree

3 files changed

+63
-21
lines changed

3 files changed

+63
-21
lines changed

Diff for: docs-mslearn/toolkit/changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ The following section lists features and enhancements that are currently in deve
3434
- Added documentation for the [Add-FinOpsServicePrincipal PowerShell command](powershell/hubs/Add-FinOpsServicePrincipal.md).
3535
- Created a new bicep modules to support extensibility:
3636
- The **hub-app** module tracks telemetry when an app is deployed.
37+
- The **hub-storage** module creates containers in the hub storage account.
3738

3839
**Fixed**
3940
- Workaround subnets reordering and bicep limitation

Diff for: src/templates/finops-hub/modules/hub-storage.bicep

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
//==============================================================================
5+
// Parameters
6+
//==============================================================================
7+
8+
@description('Required. Name of the publisher-specific storage account to create or update.')
9+
param storageAccountName string
10+
11+
@description('Required. Name of the storage container to create or update.')
12+
param container string
13+
14+
15+
//==============================================================================
16+
// Resources
17+
//==============================================================================
18+
19+
// Get storage account instance
20+
resource storageAccount 'Microsoft.Storage/storageAccounts@2022-09-01' existing = {
21+
name: storageAccountName
22+
23+
resource blobService 'blobServices@2022-09-01' = {
24+
name: 'default'
25+
26+
resource configContainer 'containers@2022-09-01' = {
27+
name: container
28+
properties: {
29+
publicAccess: 'None'
30+
metadata: {}
31+
}
32+
}
33+
}
34+
}
35+
36+
// TODO: Upload files
37+
// TODO: Enforce retention
38+
39+
//==============================================================================
40+
// Outputs
41+
//==============================================================================
42+
43+
output containerName string = storageAccount::blobService::configContainer.name

Diff for: src/templates/finops-hub/modules/storage.bicep

+19-21
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ var blobUploadRbacRoles = [
9696
// Resources
9797
//==============================================================================
9898

99+
// TODO: Move storage account creation to the hub-app module + output SA name
99100
resource storageAccount 'Microsoft.Storage/storageAccounts@2022-09-01' = {
100101
name: storageAccountName
101102
location: location
@@ -346,30 +347,27 @@ resource blobService 'Microsoft.Storage/storageAccounts/blobServices@2022-09-01'
346347
name: 'default'
347348
}
348349

349-
resource configContainer 'Microsoft.Storage/storageAccounts/blobServices/containers@2022-09-01' = {
350-
parent: blobService
351-
name: 'config'
352-
properties: {
353-
publicAccess: 'None'
354-
metadata: {}
350+
module configContainer 'hub-storage.bicep' = {
351+
name: 'configContainer'
352+
params: {
353+
storageAccountName: storageAccount.name
354+
container: 'config'
355355
}
356356
}
357357

358-
resource exportContainer 'Microsoft.Storage/storageAccounts/blobServices/containers@2022-09-01' = {
359-
parent: blobService
360-
name: 'msexports'
361-
properties: {
362-
publicAccess: 'None'
363-
metadata: {}
358+
module exportContainer 'hub-storage.bicep' = {
359+
name: 'exportContainer'
360+
params: {
361+
storageAccountName: storageAccount.name
362+
container: 'msexports'
364363
}
365364
}
366365

367-
resource ingestionContainer 'Microsoft.Storage/storageAccounts/blobServices/containers@2022-09-01' = {
368-
parent: blobService
369-
name: 'ingestion'
370-
properties: {
371-
publicAccess: 'None'
372-
metadata: {}
366+
module ingestionContainer 'hub-storage.bicep' = {
367+
name: 'ingestionContainer'
368+
params: {
369+
storageAccountName: storageAccount.name
370+
container: 'ingestion'
373371
}
374372
}
375373

@@ -491,10 +489,10 @@ output scriptStorageAccountResourceId string = scriptStorageAccount.id
491489
output scriptStorageAccountName string = scriptStorageAccount.name
492490

493491
@description('The name of the container used for configuration settings.')
494-
output configContainer string = configContainer.name
492+
output configContainer string = configContainer.outputs.containerName
495493

496494
@description('The name of the container used for Cost Management exports.')
497-
output exportContainer string = exportContainer.name
495+
output exportContainer string = exportContainer.outputs.containerName
498496

499497
@description('The name of the container used for normalized data ingestion.')
500-
output ingestionContainer string = ingestionContainer.name
498+
output ingestionContainer string = ingestionContainer.outputs.containerName

0 commit comments

Comments
 (0)