Skip to content

[Hub apps] Create the hub-storage module for storage setup #1492

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs-mslearn/toolkit/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ The following section lists features and enhancements that are currently in deve
- Added documentation for the [Add-FinOpsServicePrincipal PowerShell command](powershell/hubs/Add-FinOpsServicePrincipal.md).
- Created a new bicep modules to support extensibility:
- The **hub-app** module tracks telemetry when an app is deployed.
- The **hub-storage** module creates containers in the hub storage account.

**Fixed**
- Workaround subnets reordering and bicep limitation
Expand Down
43 changes: 43 additions & 0 deletions src/templates/finops-hub/modules/hub-storage.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

//==============================================================================
// Parameters
//==============================================================================

@description('Required. Name of the publisher-specific storage account to create or update.')
param storageAccountName string

@description('Required. Name of the storage container to create or update.')
param container string


//==============================================================================
// Resources
//==============================================================================

// Get storage account instance
resource storageAccount 'Microsoft.Storage/storageAccounts@2022-09-01' existing = {
name: storageAccountName

resource blobService 'blobServices@2022-09-01' = {
name: 'default'

resource configContainer 'containers@2022-09-01' = {
name: container
properties: {
publicAccess: 'None'
metadata: {}
}
}
}
}

// TODO: Upload files
// TODO: Enforce retention

//==============================================================================
// Outputs
//==============================================================================

output containerName string = storageAccount::blobService::configContainer.name
40 changes: 19 additions & 21 deletions src/templates/finops-hub/modules/storage.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ var blobUploadRbacRoles = [
// Resources
//==============================================================================

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

resource configContainer 'Microsoft.Storage/storageAccounts/blobServices/containers@2022-09-01' = {
parent: blobService
name: 'config'
properties: {
publicAccess: 'None'
metadata: {}
module configContainer 'hub-storage.bicep' = {
name: 'configContainer'
params: {
storageAccountName: storageAccount.name
container: 'config'
}
}

resource exportContainer 'Microsoft.Storage/storageAccounts/blobServices/containers@2022-09-01' = {
parent: blobService
name: 'msexports'
properties: {
publicAccess: 'None'
metadata: {}
module exportContainer 'hub-storage.bicep' = {
name: 'exportContainer'
params: {
storageAccountName: storageAccount.name
container: 'msexports'
}
}

resource ingestionContainer 'Microsoft.Storage/storageAccounts/blobServices/containers@2022-09-01' = {
parent: blobService
name: 'ingestion'
properties: {
publicAccess: 'None'
metadata: {}
module ingestionContainer 'hub-storage.bicep' = {
name: 'ingestionContainer'
params: {
storageAccountName: storageAccount.name
container: 'ingestion'
}
}

Expand Down Expand Up @@ -491,10 +489,10 @@ output scriptStorageAccountResourceId string = scriptStorageAccount.id
output scriptStorageAccountName string = scriptStorageAccount.name

@description('The name of the container used for configuration settings.')
output configContainer string = configContainer.name
output configContainer string = configContainer.outputs.containerName

@description('The name of the container used for Cost Management exports.')
output exportContainer string = exportContainer.name
output exportContainer string = exportContainer.outputs.containerName

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