Errors When Deploying .NET Applications To Azure

Errors related to Deploying .NET Applications To Azure

Errors

ContainerAppRegistryInUse

1
2
3
Error: updating Container App (Subscription: "00000000-0000-0000-0000-000000000002"
│ Resource Group Name: "demo-rg-bb8c7a39-dev"
│ Container App Name: "demo-aca-bb8c7a39-dev"): performing CreateOrUpdate: unexpected status 409 (409 Conflict) with error: ContainerAppRegistryInUse: Container App 'demo-aca-bb8c7a39-dev' has active revisions pulling images from the registries you are trying to delete. Please add back registries demoacrbb8c7a39dev.azurecr.io or deactive the revisions: demo-aca-bb8c7a39-dev--3rq25p3,demo-aca-bb8c7a39-dev--6x8q5l4,demo-aca-bb8c7a39-dev--c9gj9sn,demo-aca-bb8c7a39-dev--ffvr4sc,demo-aca-bb8c7a39-dev--indydxx,demo-aca-bb8c7a39-dev--os0hfry,demo-aca-bb8c7a39-dev--qri6938,demo-aca-bb8c7a39-dev--ttk7uqx pulling images from these registries.

Deactivate revision

1
az containerapp revision deactivate --revision demo-aca-bb8c7a39-dev--os0hfry --resource-group demo-rg-bb8c7a39-dev

multiple revisions

Also check if you actuall need revision_mode=Multiple

MissingSubscriptionRegistration

While trying to add azurerm_container_app_environment it shat the bed

1
2
3
4
5
6
7
8
9
10
11
12
13
14
azurerm_container_app_environment.demo-cae: Creating...

│ Error: creating Managed Environment (Subscription: "00000000-0000-0000-0000-000000000002"
│ Resource Group Name: "demo-rg"
│ Managed Environment Name: "demo-cae-dev"): performing CreateOrUpdate: unexpected status 409 (409 Conflict) with error: MissingSubscriptionRegistration: The subscription is not registered to use namespace 'Microsoft.App'. See https://aka.ms/rps-not-found for how to register subscriptions.

│ with azurerm_container_app_environment.demo-cae,
│ on container_app_environment.tf line 1, in resource "azurerm_container_app_environment" "demo-cae":
│ 1: resource "azurerm_container_app_environment" "demo-cae" {

│ creating Managed Environment (Subscription: "00000000-0000-0000-0000-000000000002"
│ Resource Group Name: "demo-rg"
│ Managed Environment Name: "demo-cae-dev"): performing CreateOrUpdate: unexpected status 409 (409 Conflict) with error: MissingSubscriptionRegistration: The subscription is not registered to use namespace 'Microsoft.App'. See
│ https://aka.ms/rps-not-found for how to register subscriptions.

Here https://aka.ms/rps-not-found helped us out and showed the commands to run.

  1. Query the provide
1
az provider list --query "[?namespace=='Microsoft.App']" --output table

Should output: NotRegistered

1
2
3
Namespace      RegistrationState    RegistrationPolicy
------------- ------------------- --------------------
Microsoft.App NotRegistered RegistrationRequired
  1. Register which should output Registering is still on-going. You can monitor using 'az provider show -n Microsoft.App'
1
az provider register --namespace Microsoft.App
  1. Check the status
1
az provider list --query "[?namespace=='Microsoft.App']" --output table

Registering

1
2
3
Namespace      RegistrationState    RegistrationPolicy
------------- ------------------- --------------------
Microsoft.App Registering RegistrationRequired

Registered

1
2
3
Namespace      RegistrationState    RegistrationPolicy
------------- ------------------- --------------------
Microsoft.App Registered RegistrationRequired

AuthorizationFailed - Error retrieving keys for Storage Account

Errors when trying use storage for the tfstate

1
│ Error: Failed to get existing workspaces: Error retrieving keys for Storage Account "demoiacbb8c7a39": storage.AccountsClient#ListKeys: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: Service returned an error. Status=403 Code="AuthorizationFailed" Message="The client '00000000-0000-0000-0000-000000000003' with object id '00000000-0000-0000-0000-000000000003' does not have authorization to perform action 'Microsoft.Storage/storageAccounts/listKeys/action' over scope '/subscriptions/***/resourceGroups/reference-rg/providers/Microsoft.Storage/storageAccounts/demoiacbb8c7a39' or the scope is invalid. If access was recently granted, please refresh your credentials."

We need to apply a role to this client

1
az role assignment create --assignee 00000000-0000-0000-0000-000000000003 --role Contributor --scope /subscriptions/00000000-0000-0000-0000-000000000002

AuthorizationFailed - Error creating RBCA from AZ CLI

When trying to run az ad sp create-for-rbac it shat the bed

1
2
3
(AuthorizationFailed) The client 'name.surname.admin@domain.co.nz' with object id '00000000-0000-0000-0000-000000000001' does not have authorization to perform action 'Microsoft.Authorization/roleAssignments/write' over scope '/subscriptions/00000000-0000-0000-0000-000000000002/resourceGroups/my-uat-rg/providers/Microsoft.Authorization/roleAssignments/00000000-0000-0000-0000-000000000003' or the scope is invalid. If access was recently granted, please refresh your credentials.
Code: AuthorizationFailed
Message: The client 'name.surname.admin@domain.co.nz' with object id '00000000-0000-0000-0000-000000000001' does not have authorization to perform action 'Microsoft.Authorization/roleAssignments/write' over scope '/subscriptions/00000000-0000-0000-0000-000000000002/resourceGroups/my-uat-rg/providers/Microsoft.Authorization/roleAssignments/00000000-0000-0000-0000-000000000003' or the scope is invalid. If access was recently granted, please refresh your credentials.

00000000-0000-0000-0000-000000000001 is the id for the user I login with obfuscated as name.surname.admin@domain.co.nz.

On the subscription, I needed to add role User Access Administrator for my user ‘name.surname.admin@domain.co.nz