Automation

Azure Logic Apps Standard: diagnose a managed connection after deployment before recreating it

A production runbook for separating the artifact, connections.json, Microsoft.Web/connections resource, access policy and target identity when a Standard workflow fails after deployment.

20 Oct 2026 azurelogic-appsmanaged-connectorsmanaged-identitydevopsautomationidentityobservabilitysecurityrunbookrollbackproduction

An Azure Logic Apps Standard deployment completes successfully and the workflows appear in the portal, but a Service Bus, Blob Storage or Key Vault action returns 401, 403, NotFound or Unauthorized. The quick recovery idea is to delete and recreate the managed connection in the designer. That may restore one workflow while hiding environment drift, changing the connectionRuntimeUrl, or breaking other workflows that share the connection.

The running case is a production workflow deployed from Azure DevOps. The application package contains workflow.json and connections.json; infrastructure separately deploys the Logic App, the Microsoft.Web/connections resource, its access policy and managed identity roles. After promotion, only the action that reads a Service Bus queue fails. This runbook ends with one of five decisions: repair the artifact, connection mapping, access policy, target RBAC, or roll back the deployment.

Freeze the deployment and one failed run

Do not modify the connection or its consent while collecting evidence. Preserve one failed run, the previous healthy run and the exact deployment identifiers. The display name in the designer is insufficient: link the action to a connections.json key and then to an Azure resource ID.

yaml 01-managed-connection-incident.yml
incident: INC-AUTO-631
window_utc:
start: 2026-10-20T06:40:00Z
end: open
logic_app: la-orders-prod
workflow: dispatch-orders
failed_action: read-orders
connector_key: servicebus-orders
expected_connection: /subscriptions/<prod-sub>/resourceGroups/rg-int-prod/providers/Microsoft.Web/connections/servicebus-orders-prod
expected_identity: /subscriptions/<prod-sub>/resourceGroups/rg-id-prod/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id-la-orders-prod
target: sb-orders-prod / queue orders
release:
pipeline_run: <run-id>
commit: <sha>
package_digest: <sha256>
last_known_good:
run_id: <workflow-run-id>
release: <release-id>
stop_owner: <automation-on-call>

Export action inputs and outputs under the existing masking policy. Keep the status code, connector message, tracking ID and UTC window. Do not resubmit yet: an earlier action may already have produced a side effect.

Read the complete connection chain

A Standard managed connection crosses several contracts:

  1. workflow.json references a logical connection key.
  2. connections.json maps that key to a managed API, a Microsoft.Web/connections resource and a runtime endpoint.
  3. The Logic App identity must be allowed to use that connection resource.
  4. The connection calls the target with the intended identity and audience.
  5. The target applies its own RBAC or access policy.

A managed connector using managed identity therefore has two authentication boundaries: Logic Apps to the connection, then the connection to the target service. A 403 alone does not identify which boundary rejected the call.

text 02-connection-chain.txt
workflow action
-> logical connection key in workflow.json
-> managedApiConnections entry in connections.json
-> Microsoft.Web/connections resource ID
-> connection access policy for the Logic App identity
-> ManagedServiceIdentity selected by the connection
-> target resource audience and RBAC
-> Service Bus queue, storage container or Key Vault object

This chain prevents a correct package from being mistaken for correct infrastructure. The workflow can be identical in staging and production while connections.json retains a staging subscription, region, runtime URL or identity.

Compare the artifact with the production contract

Start from the artifact that was actually promoted, not the current branch. Compare the action’s connection key, connections.json parameters, parameter files and expected app settings. Environment-specific values should be parameterized; a runtime URL or connection ID copied from a development workstation is a stop signal.

json 03-expected-connections-contract.json
{
"connectionKey": "servicebus-orders",
"apiIdSource": "WORKFLOWS_SUBSCRIPTION_ID + WORKFLOWS_LOCATION_NAME",
"connectionIdSource": "SERVICEBUS_CONNECTION_RESOURCE_ID",
"connectionRuntimeUrlSource": "servicebus-ConnectionRuntimeUrl",
"authentication": "ManagedServiceIdentity",
"forbidden": [
  "development subscription ID",
  "staging resource group",
  "literal runtime URL from local.settings.json",
  "Raw authentication key in production"
]
}

local.settings.json supports local development; it is not an Azure deployment contract. Verify that the pipeline supplies the required cloud app settings and parameters without printing their values in logs.

bash 04-runtime-inventory.sh
set -euo pipefail

RG="rg-int-prod"
APP="la-orders-prod"
CONNECTION_ID="/subscriptions/<prod-sub>/resourceGroups/rg-int-prod/providers/Microsoft.Web/connections/servicebus-orders-prod"
ARM_ENDPOINT="$(az cloud show --query endpoints.resourceManager -o tsv)"

az webapp show -g "$RG" -n "$APP" --query '{id:id,location:location,state:state,principalId:identity.principalId,userAssigned:identity.userAssignedIdentities}' -o json > logic-app-runtime.json

# Export names only. Values can contain secrets or sensitive endpoints.
az webapp config appsettings list -g "$RG" -n "$APP" --query '[].name' -o tsv | sort > app-setting-names.txt

az resource show --ids "$CONNECTION_ID" --api-version 2016-06-01 -o json > managed-connection.json

az rest --method get --url "${ARM_ENDPOINT}${CONNECTION_ID}/accessPolicies?api-version=2016-06-01" > connection-access-policies.json

The snapshot must show the intended subscription, region, connection resource and attached identity. Do not paste a connection key into an incident ticket merely to prove that a secret exists.

Separate access policy, identity and target authorization

The presence of a Microsoft.Web/connections resource does not prove that the Logic App can use it. Compare its access policy with the runtime’s effective principalId. A system-assigned identity changes when the Logic App is recreated; a policy that retains the former principal can leave the deployment green and the runtime broken.

Only then inspect authorization on the target. For a user-assigned identity, compare the ID configured in connections.json, the identity attached to the Logic App and the object carrying the roles. For a system-assigned identity, prove the Logic App’s current principal.

bash 05-check-target-authorization.sh
set -euo pipefail

PRINCIPAL_ID="<effective-principal-object-id>"
TARGET_SCOPE="/subscriptions/<prod-sub>/resourceGroups/rg-msg-prod/providers/Microsoft.ServiceBus/namespaces/sb-orders-prod"

az role assignment list --assignee-object-id "$PRINCIPAL_ID" --scope "$TARGET_SCOPE" --all --query '[].{role:roleDefinitionName,scope:scope,principalId:principalId}' -o table

The role must cover the real operation at the smallest useful scope. A read role cannot receive and delete a message; a role assigned on a neighboring namespace does not apply; valid access to the connection never replaces target-service authorization. Do not widen scope until principal, action and target agree.

Correlate deployment, control plane and run evidence

Build one timeline for connection-resource writes, access-policy changes, identity changes, app-setting updates, package deployment, workflow start and the first target denial.

kusto 06-control-plane-timeline.kql
let IncidentStart = datetime(2026-10-20T06:20:00Z);
let IncidentEnd = now();
AzureActivity
| where TimeGenerated between (IncidentStart .. IncidentEnd)
| where ResourceGroup =~ "rg-int-prod"
| where ResourceProviderValue in~ ("MICROSOFT.WEB", "MICROSOFT.LOGIC", "MICROSOFT.AUTHORIZATION")
| project TimeGenerated,
        OperationNameValue,
        ActivityStatusValue,
        ResourceId,
        Caller,
        CorrelationId
| order by TimeGenerated asc

Add the Logic Apps run tracking ID and target-service logs to that timeline. A denial in Service Bus, Storage or Key Vault evidence proves that the call reached the target. Its absence points earlier in the chain: connection mapping, access policy or runtime.

Canary without replaying business effects

Use an approved diagnostic workflow or create a bounded canary. It must use the same connection key and identity but a harmless target or operation: read test-queue metadata, list a dedicated container, or read a sentinel secret with no business value.

yaml 07-canary-gate.yml
canary:
workflow: connection-probe
trigger: manual
connection_key: servicebus-orders
operation: read-runtime-metadata
target: sb-orders-prod / queue connection-probe
correlation_id: conn-canary-20261020-01

positive_controls:
- connection resolves to the production resource ID
- expected principal appears in target-side evidence
- operation succeeds twice with the same contract

negative_controls:
- unapproved queue remains denied
- staging connection ID is absent
- no business message is consumed

stop_when:
- principal is unknown
- runtime URL points to another environment
- access requires a broader role
- canary creates a business side effect

After the correction, restart or redeploy only when that change type requires it, then rerun the canary. Resubmit the business run only after proving downstream state and idempotency.

Choose repair, validation or rollback

text 08-production-decision.txt
REPAIR THE ARTIFACT
workflow.json references the wrong key
connections.json contains another environment's ID, region or runtime URL
Promote a corrected package after proving its digest on the canary

REPAIR INFRASTRUCTURE
The Microsoft.Web/connections resource is missing or violates the contract
The access policy retains a former principal
The expected principal lacks the minimal target role

VALIDATE
Artifact, resource, access policy, identity and RBAC agree
Positive canary succeeds and negative control remains denied
Business run is idempotent or its downstream state is proven

ROLL BACK
Correct mapping cannot be restored inside the incident window
Identity or connection change broadens scope
Canary fails or creates an unexpected effect
Restore the last known-good package, parameters and infrastructure

Recreating the connection is a last resort, not a reflex. It can generate a new runtime URL, require fresh consent, change the effective identity and affect several workflows. If recreation is required, use a new name, canary it, switch one logical key, and retain the former connection until the rollback window closes.

Conclusion

A post-deployment connector failure is not simply a “broken connection.” The full chain between action, connections.json, connection resource, access policy, identity and target authorization must be proven.

The production-safe decision is to repair the boundary that drifted, validate it with a no-side-effect operation, and replay business work only after checking idempotency. When that proof is unavailable, restore the previous artifact and infrastructure contract together instead of recreating the connection blind.