Skip to content

Commit

Permalink
fixed build and release scripts, testing pipeline update
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-frankel committed Sep 15, 2019
1 parent 1df1feb commit b68c6e0
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 7 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ Full spec for each artifact type:
* [Template](https://docs.microsoft.com/en-us/rest/api/blueprints/artifacts/createorupdate#templateartifact)

### How Parameters work
Nearly everything can be parameterized. The only things that can't be parameterized are the `roleDefinitionId` and `policyDefinitionId` in the `rbacAssignment` and `policyAssignment` artifacts respectively.
Nearly everything in a blueprint definition can be parameterized. The only things that can't be parameterized are the `roleDefinitionId` and `policyDefinitionId` in the `rbacAssignment` and `policyAssignment` artifacts respectively.
Parameters are defined in the main blueprint file and can be referenced in any artifact.

Here's a simple parameter declaration which is a simplified version from `blueprint.json`:
Expand Down Expand Up @@ -234,6 +234,15 @@ You can also use the `New-AzBlueprintArtifact` cmdlet to convert a standard ARM
New-AzBlueprintArtifact -Type TemplateArtifact -Name storage-account -Blueprint $bp -TemplateFile C:\StorageAccountArmTemplate.json -ResourceGroup "storageRG" -TemplateParameterFile "C:\StorageAccountParams.json"
```

#### How blueprint parameters display during assignment in the Azure Portal
When you assign a blueprint in the Azure Portal, the parameters will be diplayed according to how they are referenced. If a parameter is used by multiple artifacts, it will be displayed as a blueprint parameter. Like this:

![Image of blueprint parameters](./images/bp-params.PNG)

If it is used by a single artifact, it will be displayed only in the context of that artifact, like so:

![Image of artifact parameters](./images/artifact-params.PNG)

### Passing values between artifacts
There are many reasons you may want or need to pass the output from one artifact as the input to another artifact that is deployed later in the blueprint assignment sequence. If so, you can make use of the ```artifacts()``` function which lets you reference the details of a particular artifact.

Expand Down
4 changes: 3 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ pool: 'Hosted VS2017'
variables:
- name: spnName
value: 'pipelines-runner'
- name: blueprintPath
value: '.\samples\'
- name: blueprintName
value: '101-boilerplate'
- name: subscriptionId
Expand All @@ -26,7 +28,7 @@ steps:
inputs:
azureSubscription: $(spnName)
BlueprintName: $(blueprintName)
BlueprintPath: '.\$(blueprintName)'
BlueprintPath: '$(blueprintsPath)$(blueprintName)' # would need to edit this to work with built-ins
AlternateLocation: false
PublishBlueprint: true

Expand Down
Binary file added images/artifact-params.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/bp-params.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions pipelines-scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ param(
$PSVersionTable.PSVersion # Assuming powershell core (6)

Write-Host "Installing Az module"
# Get-Module -ListAvailable
Install-Module -Name Az.Blueprint -AllowClobber
Install-Module -Name Az.Blueprint -AllowClobber # todo - check installation status
Write-Host "Successfully installed Az.Blueprint module"

Write-Host "Start login with SPN"
$pass = ConvertTo-SecureString $spnPass -AsPlainText -Force
$cred = New-Object -TypeName pscredential -ArgumentList $spnId, $pass
Login-AzAccount -Credential $cred -ServicePrincipal -TenantId $tenantId
Write-Host "Successfully logged in with SPN"

Write-Host "Azure context:"
Get-AzContext
Expand Down
6 changes: 3 additions & 3 deletions pipelines-scripts/release.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
param(
[Parameter(Mandatory=$true)]$mgId,
[Parameter(Mandatory=$true)]$BlueprintFolder,
[Parameter(Mandatory=$true)]$blueprintName,
[Parameter(Mandatory=$true)]$spnId,
[Parameter(Mandatory=$true)]$spnPass,
Expand All @@ -12,7 +11,7 @@ param(
# Output powershell version for debugging purposes and is probably generally good to know
$PSVersionTable.PSVersion # Assuming powershell core (6)

Write-Host "Installing Az module"
Write-Host "Installing Az module" # todo - should check if blueprint module is already installed
Install-Module -Name Az.Blueprint -AllowClobber
Write-Host "Successfully installed Az.Blueprint module"

Expand All @@ -26,10 +25,11 @@ Get-AzContext

$importedBp = Get-AzBlueprint -ManagementGroupId $mgId -Name $blueprintName -LatestPublished
# Urgent TODO - this should be idemopotent...
# todo - should auto-insert blueprintId into parameters file
New-AzBlueprintAssignment -Name "pla-$blueprintName" -Blueprint $importedBp -AssignmentFile $parametersPath -SubscriptionId $subscriptionId

# Wait for assignment to complete
$timeout = new-timespan -Seconds 5
$timeout = new-timespan -Seconds 500
$sw = [diagnostics.stopwatch]::StartNew()

while (($sw.elapsed -lt $timeout) -and ($AssignemntStatus.ProvisioningState -ne "Succeeded") -and ($AssignemntStatus.ProvisioningState -ne "Failed")) {
Expand Down

0 comments on commit b68c6e0

Please sign in to comment.