Development edition · 16 November 2026. Commands using repository paths, Make targets or sample projects require access to the Quinzee source checkout. No public installer is available. Examples use disposable local environments.
28. Deploy application hosts and their identities
Run the infrastructure workshop first. Each file below is complete and deploys at resource-group scope. Use a separate deployment name for each lesson so its operation history is easy to find.
Create a workload identity with a scoped role
Generate one UUID for assignmentName and retain it in the private parameters file for future redeployments. The template creates a user-assigned identity and gives it Reader at the deployment resource-group scope. The generated principal ID identifies the tenant object; the client ID identifies the OAuth client.
Step 1: save the Bicep
The repository copy is examples/book-iac/identity-rbac.bicep. To experiment, save this complete sample to .local/book-iac/identity-rbac.bicep:
targetScope = 'resourceGroup'
param prefix string = 'booklab'
param location string = resourceGroup().location
param assignmentName string
resource identity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
name: '${prefix}-reader'
location: location
}
resource reader 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
name: assignmentName
properties: {
principalId: identity.properties.principalId
principalType: 'ServicePrincipal'
roleDefinitionId: '/subscriptions/${subscription().subscriptionId}/providers/Microsoft.Authorization/roleDefinitions/acdd72a7-3385-48ef-bd42-f606fba81ae7'
}
}
output clientId string = identity.properties.clientId
output principalId string = identity.properties.principalId
Step 2: inspect the ARM equivalent
The compiler emits these resource objects. The surrounding template also contains the parameters and outputs declared above. Expressions in square brackets are evaluated by the deployment engine, not by your shell.
[
{
"type": "Microsoft.ManagedIdentity/userAssignedIdentities",
"apiVersion": "2023-01-31",
"name": "[format('{0}-reader', parameters('prefix'))]",
"location": "[parameters('location')]"
},
{
"type": "Microsoft.Authorization/roleAssignments",
"apiVersion": "2022-04-01",
"name": "[parameters('assignmentName')]",
"properties": {
"principalId": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', format('{0}-reader', parameters('prefix'))), '2023-01-31').principalId]",
"principalType": "ServicePrincipal",
"roleDefinitionId": "[format('/subscriptions/{0}/providers/Microsoft.Authorization/roleDefinitions/acdd72a7-3385-48ef-bd42-f606fba81ae7', subscription().subscriptionId)]"
},
"dependsOn": [
"[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', format('{0}-reader', parameters('prefix')))]"
]
}
]
Step 3: compile, deploy and check
python3 scripts/deps/bicep.py build .local/book-iac/identity-rbac.bicep \
--outfile .local/book-iac/identity-rbac.json
Supply these required parameters: assignmentName. Run the deployment command from the workshop with --name identity-rbac, --template .local/book-iac/identity-rbac.json and a distinct outputs filename. Add --parameters when supplying inputs. Select the same deployment in QHQ and wait for Succeeded.
QHQ shows the identity and role assignment. It has no password and cannot obtain a token from an arbitrary laptop: attach it to a supported hosted app. Reader grants resource reads, not message send/receive and not directory administration. Use one stable assignment UUID per intended principal/role/scope tuple.
Run a web application behind HTTPS
Build the minimal web image in the App Service walkthrough, register quinzee-book-web:local with the hosting helper, and keep the helper running. The App Service walkthrough explains those commands. The plan and app use the same group and location. The system identity is created with the site but receives no resource permissions automatically.
Step 1: save the Bicep
The repository copy is examples/book-iac/app-service.bicep. To experiment, save this complete sample to .local/book-iac/app-service.bicep:
targetScope = 'resourceGroup'
param prefix string = 'booklab'
param location string = resourceGroup().location
param image string = 'quinzee-book-web:local'
resource plan 'Microsoft.Web/serverfarms@2024-11-01' = {
name: '${prefix}-web-plan'
location: location
kind: 'linux'
sku: { name: 'B1', tier: 'Basic', capacity: 1 }
properties: { reserved: true }
}
resource web 'Microsoft.Web/sites@2024-11-01' = {
name: '${prefix}-web'
location: location
kind: 'app,linux,container'
identity: { type: 'SystemAssigned' }
properties: {
serverFarmId: plan.id
httpsOnly: true
reserved: true
siteConfig: {
linuxFxVersion: 'DOCKER|${image}'
alwaysOn: true
appSettings: [{ name: 'Greeting', value: 'Hello from infrastructure as code' }]
}
}
}
output hostname string = web.properties.defaultHostName
output principalId string = web.identity.principalId
Step 2: inspect the ARM equivalent
The compiler emits these resource objects. The surrounding template also contains the parameters and outputs declared above. Expressions in square brackets are evaluated by the deployment engine, not by your shell.
[
{
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2024-11-01",
"name": "[format('{0}-web-plan', parameters('prefix'))]",
"location": "[parameters('location')]",
"kind": "linux",
"sku": {
"name": "B1",
"tier": "Basic",
"capacity": 1
},
"properties": {
"reserved": true
}
},
{
"type": "Microsoft.Web/sites",
"apiVersion": "2024-11-01",
"name": "[format('{0}-web', parameters('prefix'))]",
"location": "[parameters('location')]",
"kind": "app,linux,container",
"identity": {
"type": "SystemAssigned"
},
"properties": {
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', format('{0}-web-plan', parameters('prefix')))]",
"httpsOnly": true,
"reserved": true,
"siteConfig": {
"linuxFxVersion": "[format('DOCKER|{0}', parameters('image'))]",
"alwaysOn": true,
"appSettings": [
{
"name": "Greeting",
"value": "Hello from infrastructure as code"
}
]
}
},
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', format('{0}-web-plan', parameters('prefix')))]"
]
}
]
Step 3: compile, deploy and check
python3 scripts/deps/bicep.py build .local/book-iac/app-service.bicep \
--outfile .local/book-iac/app-service.json
This file has defaults for every parameter. Run the deployment command from the workshop with --name app-service, --template .local/book-iac/app-service.json and a distinct outputs filename. Add --parameters when supplying inputs. Select the same deployment in QHQ and wait for Succeeded.
The deployment completes when the helper verifies the app. Open the returned hostname through the lab DNS and trusted CA. The included web app returns its Greeting at /. Change Greeting, redeploy, and observe the replacement container serving the new value.
Deploy HTTP and queue-triggered code
Build make functions-example, register the image and keep the helper running. Deploy the Service Bus lesson first, then obtain its connection string privately as shown in the messaging chapter. Supply serviceBusConnection as a secure parameter; use a unique appName.
Step 1: save the Bicep
The repository copy is examples/book-iac/functions.bicep. To experiment, save this complete sample to .local/book-iac/functions.bicep:
param appName string = 'quinzee-functions'
param image string = 'quinzee-functions-example:local'
@secure()
param serviceBusConnection string
param location string = resourceGroup().location
resource plan 'Microsoft.Web/serverfarms@2024-11-01' = {
name: '${appName}-plan'
location: location
kind: 'linux'
sku: { name: 'B1', tier: 'Basic', capacity: 1 }
properties: { reserved: true }
}
resource app 'Microsoft.Web/sites@2024-11-01' = {
name: appName
location: location
kind: 'functionapp,linux,container'
properties: {
serverFarmId: plan.id
httpsOnly: true
reserved: true
siteConfig: {
linuxFxVersion: 'DOCKER|${image}'
alwaysOn: true
appSettings: [
{ name: 'Greeting', value: 'from Bicep' }
{ name: 'ServiceBusConnection', value: serviceBusConnection }
]
}
}
}
output hostname string = app.properties.defaultHostName
Step 2: inspect the ARM equivalent
The compiler emits these resource objects. The surrounding template also contains the parameters and outputs declared above. Expressions in square brackets are evaluated by the deployment engine, not by your shell.
[
{
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2024-11-01",
"name": "[format('{0}-plan', parameters('appName'))]",
"location": "[parameters('location')]",
"kind": "linux",
"sku": {
"name": "B1",
"tier": "Basic",
"capacity": 1
},
"properties": {
"reserved": true
}
},
{
"type": "Microsoft.Web/sites",
"apiVersion": "2024-11-01",
"name": "[parameters('appName')]",
"location": "[parameters('location')]",
"kind": "functionapp,linux,container",
"properties": {
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', format('{0}-plan', parameters('appName')))]",
"httpsOnly": true,
"reserved": true,
"siteConfig": {
"linuxFxVersion": "[format('DOCKER|{0}', parameters('image'))]",
"alwaysOn": true,
"appSettings": [
{
"name": "Greeting",
"value": "from Bicep"
},
{
"name": "ServiceBusConnection",
"value": "[parameters('serviceBusConnection')]"
}
]
}
},
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', format('{0}-plan', parameters('appName')))]"
]
}
]
Step 3: compile, deploy and check
python3 scripts/deps/bicep.py build .local/book-iac/functions.bicep \
--outfile .local/book-iac/functions.json
Supply these required parameters: serviceBusConnection. Run the deployment command from the workshop with --name functions, --template .local/book-iac/functions.json and a distinct outputs filename. Add --parameters when supplying inputs. Select the same deployment in QHQ and wait for Succeeded.
The returned host serves /api/echo; the Functions host enforces its function key. Sending to orders runs the Service Bus trigger. The real application image must contain the referenced binding. ARM provisions infrastructure; it does not compile C# or install missing extensions.
Replace the messaging secret with a managed identity
Use a fresh app name and the existing namespace name. Retain a stable roleAssignmentName UUID. This template grants Receiver to the user-assigned identity at resource-group scope, attaches it, and supplies the binding's identity settings. For a narrower grant, use the explicit namespace/entity role-assignment API instead.
Step 1: save the Bicep
The repository copy is examples/book-iac/functions-identity.bicep. To experiment, save this complete sample to .local/book-iac/functions-identity.bicep:
// Secret-free queue processing with a user-assigned identity and scoped role.
// Quinzee Cloud - proprietary and confidential. All rights reserved.
param appName string = 'quinzee-identity-functions'
param namespaceName string
param image string = 'quinzee-functions-example:local'
param roleAssignmentName string = '5486a231-5229-46aa-913d-3fd405af9958'
param location string = resourceGroup().location
resource identity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
name: '${appName}-identity'
location: location
}
resource receiver 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
name: roleAssignmentName
properties: {
principalId: identity.properties.principalId
principalType: 'ServicePrincipal'
roleDefinitionId: '/subscriptions/${subscription().subscriptionId}/providers/Microsoft.Authorization/roleDefinitions/4f6d3b9b-027b-4f4c-9142-0e5a2a2247e0'
}
}
resource plan 'Microsoft.Web/serverfarms@2024-11-01' = {
name: '${appName}-plan'
location: location
kind: 'linux'
sku: { name: 'B1', tier: 'Basic', capacity: 1 }
properties: { reserved: true }
}
resource app 'Microsoft.Web/sites@2024-11-01' = {
name: appName
location: location
kind: 'functionapp,linux,container'
identity: {
type: 'UserAssigned'
userAssignedIdentities: { '${identity.id}': {} }
}
dependsOn: [receiver]
properties: {
serverFarmId: plan.id
httpsOnly: true
reserved: true
siteConfig: {
linuxFxVersion: 'DOCKER|${image}'
alwaysOn: true
appSettings: [
{ name: 'Greeting', value: 'from Bicep' }
{ name: 'ServiceBusConnection__fullyQualifiedNamespace', value: '${namespaceName}.servicebus.quinzee.cloud' }
{ name: 'ServiceBusConnection__credential', value: 'managedidentity' }
{ name: 'ServiceBusConnection__clientId', value: identity.properties.clientId }
]
}
}
}
output hostname string = app.properties.defaultHostName
output principalId string = identity.properties.principalId
Step 2: inspect the ARM equivalent
The compiler emits these resource objects. The surrounding template also contains the parameters and outputs declared above. Expressions in square brackets are evaluated by the deployment engine, not by your shell.
[
{
"type": "Microsoft.ManagedIdentity/userAssignedIdentities",
"apiVersion": "2023-01-31",
"name": "[format('{0}-identity', parameters('appName'))]",
"location": "[parameters('location')]"
},
{
"type": "Microsoft.Authorization/roleAssignments",
"apiVersion": "2022-04-01",
"name": "[parameters('roleAssignmentName')]",
"properties": {
"principalId": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', format('{0}-identity', parameters('appName'))), '2023-01-31').principalId]",
"principalType": "ServicePrincipal",
"roleDefinitionId": "[format('/subscriptions/{0}/providers/Microsoft.Authorization/roleDefinitions/4f6d3b9b-027b-4f4c-9142-0e5a2a2247e0', subscription().subscriptionId)]"
},
"dependsOn": [
"[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', format('{0}-identity', parameters('appName')))]"
]
},
{
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2024-11-01",
"name": "[format('{0}-plan', parameters('appName'))]",
"location": "[parameters('location')]",
"kind": "linux",
"sku": {
"name": "B1",
"tier": "Basic",
"capacity": 1
},
"properties": {
"reserved": true
}
},
{
"type": "Microsoft.Web/sites",
"apiVersion": "2024-11-01",
"name": "[parameters('appName')]",
"location": "[parameters('location')]",
"kind": "functionapp,linux,container",
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"[format('{0}', resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', format('{0}-identity', parameters('appName'))))]": {}
}
},
"properties": {
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', format('{0}-plan', parameters('appName')))]",
"httpsOnly": true,
"reserved": true,
"siteConfig": {
"linuxFxVersion": "[format('DOCKER|{0}', parameters('image'))]",
"alwaysOn": true,
"appSettings": [
{
"name": "Greeting",
"value": "from Bicep"
},
{
"name": "ServiceBusConnection__fullyQualifiedNamespace",
"value": "[format('{0}.servicebus.quinzee.cloud', parameters('namespaceName'))]"
},
{
"name": "ServiceBusConnection__credential",
"value": "managedidentity"
},
{
"name": "ServiceBusConnection__clientId",
"value": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', format('{0}-identity', parameters('appName'))), '2023-01-31').clientId]"
}
]
}
},
"dependsOn": [
"[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', format('{0}-identity', parameters('appName')))]",
"[resourceId('Microsoft.Web/serverfarms', format('{0}-plan', parameters('appName')))]",
"[resourceId('Microsoft.Authorization/roleAssignments', parameters('roleAssignmentName'))]"
]
}
]
Step 3: compile, deploy and check
python3 scripts/deps/bicep.py build .local/book-iac/functions-identity.bicep \
--outfile .local/book-iac/functions-identity.json
Supply these required parameters: namespaceName. Run the deployment command from the workshop with --name functions-identity, --template .local/book-iac/functions-identity.json and a distinct outputs filename. Add --parameters when supplying inputs. Select the same deployment in QHQ and wait for Succeeded.
With SAS disabled on the namespace, the trigger still receives work using a Service Bus audience token. Removing the receiver assignment prevents further receives. The role is an Azure resource permission; app roles on an Enterprise application do not grant Service Bus access.