Skip to content
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

[Modules] Microsoft.PowerBIDedicated/capacities module #1978

Merged
Show file tree
Hide file tree
Changes from 5 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
40 changes: 40 additions & 0 deletions .azuredevops/modulePipelines/ms.powerbidedicated.capacities.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: 'PowerBIDedicated - Capacities'

parameters:
- name: removeDeployment
displayName: Remove deployed module
type: boolean
default: true
- name: prerelease
displayName: Publish prerelease module
type: boolean
default: false

pr: none

trigger:
batch: true
branches:
include:
- main
paths:
include:
- '/.azuredevops/modulePipelines/ms.powerbidedicated.capacities.yml'
- '/.azuredevops/pipelineTemplates/*.yml'
- '/modules/Microsoft.PowerBIDedicated/capacities/*'
- '/utilities/pipelines/*'
exclude:
- '/utilities/pipelines/dependencies/*'
- '/**/*.md'

variables:
- template: '../../settings.yml'
- group: 'PLATFORM_VARIABLES'
- name: modulePath
value: '/modules/Microsoft.PowerBIDedicated/capacities'

stages:
- template: /.azuredevops/pipelineTemplates/stages.module.yml
parameters:
removeDeployment: '${{ parameters.removeDeployment }}'
prerelease: '${{ parameters.prerelease }}'
146 changes: 146 additions & 0 deletions .github/workflows/ms.powerbidedicated.capacities.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
name: 'PowerBiDedicated: capacities'

on:
workflow_dispatch:
inputs:
removeDeployment:
type: boolean
description: 'Remove deployed module'
required: false
default: true
prerelease:
type: boolean
description: 'Publish prerelease module'
required: false
default: false
push:
branches:
- main
paths:
- '.github/actions/templates/**'
- '.github/workflows/ms.powerbidedicated.capacities.yml'
- 'modules/Microsoft.PowerBIDedicated/capacities/**'
- 'utilities/pipelines/**'
- '!utilities/pipelines/dependencies/**'
- '!*/**/readme.md'

env:
variablesPath: 'settings.yml'
modulePath: 'modules/Microsoft.PowerBIDedicated/capacities'
workflowPath: '.github/workflows/ms.aad.capacities.yml'
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
ARM_SUBSCRIPTION_ID: '${{ secrets.ARM_SUBSCRIPTION_ID }}'
ARM_MGMTGROUP_ID: '${{ secrets.ARM_MGMTGROUP_ID }}'
ARM_TENANT_ID: '${{ secrets.ARM_TENANT_ID }}'
DEPLOYMENT_SP_ID: '${{ secrets.DEPLOYMENT_SP_ID }}'

jobs:
###########################
# Initialize pipeline #
###########################
job_initialize_pipeline:
runs-on: ubuntu-20.04
name: 'Initialize pipeline'
steps:
- name: 'Checkout'
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: 'Set input parameters to output variables'
id: get-workflow-param
uses: ./.github/actions/templates/getWorkflowInput
with:
workflowPath: '${{ env.workflowPath}}'
- name: 'Get parameter file paths'
id: get-parameter-file-paths
uses: ./.github/actions/templates/getParameterFiles
with:
modulePath: '${{ env.modulePath }}'
outputs:
removeDeployment: ${{ steps.get-workflow-param.outputs.removeDeployment }}
parameterFilePaths: ${{ steps.get-parameter-file-paths.outputs.parameterFilePaths }}

#########################
# Static validation #
#########################
job_module_pester_validation:
runs-on: ubuntu-20.04
name: 'Static validation'
steps:
- name: 'Checkout'
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set environment variables
uses: ./.github/actions/templates/setEnvironmentVariables
with:
variablesPath: ${{ env.variablesPath }}
- name: 'Run tests'
uses: ./.github/actions/templates/validateModulePester
with:
modulePath: '${{ env.modulePath }}'
moduleTestFilePath: '${{ env.moduleTestFilePath }}'

#############################
# Deployment validation #
#############################
job_module_deploy_validation:
runs-on: ubuntu-20.04
name: 'Deployment validation'
needs:
- job_initialize_pipeline
- job_module_pester_validation
strategy:
fail-fast: false
matrix:
parameterFilePaths: ${{ fromJSON(needs.job_initialize_pipeline.outputs.parameterFilePaths) }}
steps:
- name: 'Checkout'
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set environment variables
uses: ./.github/actions/templates/setEnvironmentVariables
with:
variablesPath: ${{ env.variablesPath }}
- name: 'Using parameter file [${{ matrix.parameterFilePaths }}]'
uses: ./.github/actions/templates/validateModuleDeployment
with:
templateFilePath: '${{ env.modulePath }}/deploy.bicep'
parameterFilePath: '${{ env.modulePath }}/${{ matrix.parameterFilePaths }}'
location: '${{ env.location }}'
resourceGroupName: '${{ env.resourceGroupName }}'
subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}'
managementGroupId: '${{ secrets.ARM_MGMTGROUP_ID }}'
removeDeployment: '${{ needs.job_initialize_pipeline.outputs.removeDeployment }}'

##################
# Publishing #
##################
job_publish_module:
name: 'Publishing'
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || github.event.inputs.prerelease == 'true'
runs-on: ubuntu-20.04
needs:
- job_module_deploy_validation
steps:
- name: 'Checkout'
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set environment variables
uses: ./.github/actions/templates/setEnvironmentVariables
with:
variablesPath: ${{ env.variablesPath }}
- name: 'Publishing'
uses: ./.github/actions/templates/publishModule
with:
templateFilePath: '${{ env.modulePath }}/deploy.bicep'
templateSpecsRGName: '${{ env.templateSpecsRGName }}'
templateSpecsRGLocation: '${{ env.templateSpecsRGLocation }}'
templateSpecsDescription: '${{ env.templateSpecsDescription }}'
templateSpecsDoPublish: '${{ env.templateSpecsDoPublish }}'
bicepRegistryName: '${{ env.bicepRegistryName }}'
bicepRegistryRGName: '${{ env.bicepRegistryRGName }}'
bicepRegistryRgLocation: '${{ env.bicepRegistryRgLocation }}'
bicepRegistryDoPublish: '${{ env.bicepRegistryDoPublish }}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
param roleAssignmentObj object
param resourceName string

var builtInRoleNames = {
'Owner': subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '8e3af657-a8ff-443c-a75c-2fe8c4bcb635')
'Contributor': subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c')
'Reader': subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'acdd72a7-3385-48ef-bd42-f606fba81ae7')
'Log Analytics Contributor': subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '92aaf0da-9dab-42b6-94a3-d43ce8d16293')
'Log Analytics Reader': subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '73c42c96-874c-492b-b04d-ab87d138a893')
'Managed Application Contributor Role': subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '641177b8-a67a-45b9-a033-47bc880bb21e')
'Managed Application Operator Role': subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'c7393b34-138c-406f-901b-d8cf2b17e6ae')
'Managed Applications Reader': subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b9331d33-8a36-4f8c-b097-4f54124fdb44')
'Monitoring Contributor': subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '749f88d5-cbae-40b8-bcfc-e573ddc772fa')
'Monitoring Metrics Publisher': subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '3913510d-42f4-4e42-8a64-420c390055eb')
'Monitoring Reader': subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '43d0d8ad-25c7-4714-9337-8ba259a9fe05')
'Resource Policy Contributor': subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '36243c78-bf99-498c-9df9-86d9f8d28608')
'User Access Administrator': subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '18d7d88d-d35e-4fb5-a5c3-7773c20a72d9')
}

resource powerbi 'Microsoft.PowerBIDedicated/capacities@2021-01-01' existing = {
name: resourceName
}

resource roleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = [for principalId in roleAssignmentObj.principalIds: {
name: guid(powerbi.name, principalId, roleAssignmentObj.roleDefinitionIdOrName)
properties: {
roleDefinitionId: contains(builtInRoleNames, roleAssignmentObj.roleDefinitionIdOrName) ? builtInRoleNames[roleAssignmentObj.roleDefinitionIdOrName] : roleAssignmentObj.roleDefinitionIdOrName
principalId: principalId
}
scope: powerbi
}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"name": {
"value": "<<namePrefix>>azpbid001"
},
"skuCapacity": {
"value": 1
},
"members": {
"value": [
"<<deploymentSpId>>"
]
}
}
}
98 changes: 98 additions & 0 deletions modules/Microsoft.PowerBIDedicated/capacities/deploy.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
@description('Required. Name of the PowerBI Embedded.')
param name string

@description('Optional. Location for all Resources.')
param location string = resourceGroup().location

@description('Optional. Tags of the resource.')
param tags object = {}

@description('Required. SkuCapacity of the resource.')
param skuCapacity int

@allowed([
'A1'
'A2'
'A3'
'A4'
'A5'
'A6'
])
@description('Optional. SkuCapacity of the resource.')
param skuName string = 'A1'

@allowed([
'AutoPremiumHost'
'PBIE_Azure'
'Premium'
])
@description('Optional. SkuCapacity of the resource.')
param skuTier string = 'PBIE_Azure'

@description('Required. Members of the resource.')
param members array

@allowed([
'Gen1'
'Gen2'
])
@description('Optional. Mode of the resource.')
param mode string = 'Gen2'

@allowed([
''
'CanNotDelete'
'NotSpecified'
'ReadOnly'
])
@description('Optional. Specify the type of lock.')
param lock string = ''

@description('Optional. Array of role assignment objects that contain the \'roleDefinitionIdOrName\' and \'principalId\' to define RBAC role assignments on this resource. In the roleDefinitionIdOrName attribute, you can provide either the display name of the role definition, or its fully qualified ID in the following format: \'/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11\'.')
param roleAssignments array = []

resource powerbi 'Microsoft.PowerBIDedicated/capacities@2021-01-01' = {
name: name
location: location
tags: tags
sku: {
capacity: skuCapacity
name: skuName
tier: skuTier
}
properties: {
administration: {
members: members
}
mode: mode
}
}

resource powerbi_lock 'Microsoft.Authorization/locks@2016-09-01' = if (!empty(lock)) {
name: '${powerbi.name}-${lock}-lock'
properties: {
level: lock
notes: lock == 'CanNotDelete' ? 'Cannot delete resource or child resources.' : 'Cannot modify the resource or child resources.'
}
scope: powerbi
}

module powerbi_rbac '.bicep/nested_rbac.bicep' = [for (roleAssignment, index) in roleAssignments: {
name: '${deployment().name}-rbac-${index}'
params: {
roleAssignmentObj: roleAssignment
resourceName: powerbi.name
}
}]

@description('The resource ID of the recovery services vault.')
output resourceId string = powerbi.id

@description('The name of the resource group the recovery services vault was created in.')
eriqua marked this conversation as resolved.
Show resolved Hide resolved
output resourceGroupName string = resourceGroup().name

@description('The Name of the recovery services vault.')
output name string = powerbi.name

@description('The location the resource was deployed into.')
output location string = powerbi.location
Loading