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

Spike: Review updating bicep examples to reflect using bicep to retrieve output variables of previous deployment #517

Closed
shawngib opened this issue Nov 11, 2021 · 1 comment
Assignees
Labels
spike A time-boxed effort to answer a question

Comments

@shawngib
Copy link
Member

Is your feature request related to a problem? Please describe.
To work with existing MLZ deployment in an effort to add additional capabilities or workloads it important to know a number of outputs of existing deployment to place as parameters into new deployment. Our current example for new work load uses a cli command to pull the json:

az deployment sub show \
  --subscription $deploymentSubscription \
  --name "myMlzDeployment" \
  --query properties.outputs

The goal is to create workload deployment bicep code that doesn;t require manually adding this output as input to the new deployment. Currently looks like this:

workloadSubscriptionId="12345678-1234..."
location="eastus"
workloadName="myNewWorkload"

az deployment sub create \
  --subscription $workloadSubscriptionId \
  --location $location \
  --name $workloadName \
  --template-file "./newWorkload.bicep" \
  --parameters \
  workloadName="$workloadName" \
  hubSubscriptionId="$hubSubscriptionId" \
<additonal parameters removed to brevity>

Describe the solution you'd like
For the solution it is recommended to use a bicep resource by calling Microsoft.Resources/deployments@2021-04-01 existing and then referencing its output in the new module or main file.

Example:

targetScope = 'subscription'

param name string

resource deployments 'Microsoft.Resources/deployments@2021-04-01' existing = {
  name: name
}

output deploymentsObj object = deployments

Describe alternatives you've considered
Alternatives are to use scripting and local files.

@shawngib shawngib changed the title Update bicep examples to reflect using bicep to retrieve output variables of previous deployment [SPIKE] Review updating bicep examples to reflect using bicep to retrieve output variables of previous deployment Nov 12, 2021
@brooke-hamilton brooke-hamilton changed the title [SPIKE] Review updating bicep examples to reflect using bicep to retrieve output variables of previous deployment Review updating bicep examples to reflect using bicep to retrieve output variables of previous deployment Nov 15, 2021
@brooke-hamilton brooke-hamilton added the spike A time-boxed effort to answer a question label Nov 15, 2021
@brooke-hamilton brooke-hamilton changed the title Review updating bicep examples to reflect using bicep to retrieve output variables of previous deployment Spike: Review updating bicep examples to reflect using bicep to retrieve output variables of previous deployment Nov 15, 2021
@shawngib
Copy link
Member Author

shawngib commented Nov 18, 2021

Final test prove this to be not sufficient. The primary problem is in the early stages of the ARM pipeline. While some output maybe available the result of arrays are unknown so the bicep/arm code doesn't understand looping and indexes in the array so referring to them in the subsequent deployment will fail for 'not knowing' .

This should be tracked since this should work in the future but for purposes needed today it is not a working solution.

There still maybe an opportunity to stay all Bicep by using the above to create the output file and simply referring to it in the new deployment file. For example:

az deployment sub create -f ./Mission.Workload/variables.bicep -n shawngibbs18 -l usgovvirginia  > output.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
spike A time-boxed effort to answer a question
Projects
None yet
Development

No branches or pull requests

2 participants