Building and Deploying the BPE Blog Admin UI
The past couple of weeks have mostly been focused on delivering an API at work, so most of my development time has been spent on implementation and building out the CI/CD pipelines to get it into our development environment.
Luckily enough, the BPE Blog API was reaching roughly the same point in its lifecycle. The API was in place and it was time to start implementing the UI and the CI/CD required to actually get everything running in Azure.
Building the Admin UI
The first step was creating the admin UI.
UI design has always been a struggle for me — insert the obligatory “center a div” joke here — and this is one of the areas where I’ve found Codex particularly useful. I generally know what behavior I want from an application, but turning that into an attractive UI isn’t necessarily one of my strengths.
I started by giving Codex the following prompt to generate an Angular application using Angular Material:
use environment settings to point local to https://localhost:7036
let's implement these features:
- Blog Post List
- calls GET api/blog-posts
- if there are no posts returned then show "No blog posts created, create one now"
- create one now should send us to the create blog post component
- when entries exist, clicking on the row should navigate to the blog post details component
- should be paginated, max 15 per page
- Create Blog Post
- calls POST api/blog-posts
- should be a form component that creates the create blog post request defined in the BPE Blog API (feel free to reference that workspace to get the shape)
- should validate that at least the title is present
- Blog Post Details
- calls GET api/blog-posts/{id}
- should be a form component that allows to edit the title, description, tags, and content
- there should be a preview button that allows you to view the content property adjacent to the text editor
- preview should update in real time as the user types, displaying the markdown, similar to the markdown preview in VS Code
- while the preview is up, the other views should disappear from view
- there should be a save and publish button at the top right; they should have no function for now
- there should be a delete button alongside these; it should call DELETE api/blog-posts/{id} when clicked
- when clicking delete, it should have a confirmation modal "Are you sure you want to delete this post?"
we should also use angular material
we should also implement a toolbar at the top with a user menu at the top right, use a standard more_vert icon for the user menu
- by default, we should see a login screen if we aren't authenticated
- login screen should have a welcome message and a "Log in with BPE Entra" button
- we should use MSAL to login with Entra (unless there are better options available; if so prompt me with suggestions)
- it should direct to the BPE login
- user menu should display the logged in user's name, a dark/light mode toggle, and a logout button
Using this prompt, we got a simple but attractive UI.
I’ve used Codex for similar work pretty extensively with Trakr, where I used it to take what was originally a pretty boring, flat Angular UI and turn it into something considerably more polished.
The same approach worked pretty well here.
For me, this is probably one of the biggest benefits of using Codex. I can define the behavior and structure I’m looking for while letting it handle a lot of the visual implementation that I probably wouldn’t spend nearly as much time on myself.
Adding Authentication
Now that we had the baseline UI in place, the next step was securing it.
The API was already secured using Entra, so I created another app registration specifically for the admin UI and granted it access to the Blog.Admin scope exposed by the API.
I then gave Codex the UI app registration details:
update the entra setup
fccba23e-6ff8-42fc-a6c3-f9ca6a6cfea8 is the client id for this UI
redirect url should be /
logout redirect url should be to the login screen
Authentication worked.
But of course, the Auth God giveth, and the CORS God taketh away.
The UI could authenticate successfully with Entra, but the browser still wasn’t allowed to call the API from a different origin.
Authentication and browser access are two separate concerns, so we needed to explicitly allow the UI through the API’s CORS configuration.
add a CORS policy to the BPE Blog API
- derive the value from configuration with key "Admin UI"
- for development, it should be https://localhost:4200; prod we can leave alone for now
And voilà, I could finally view all of the blog posts I’d created so far, including the test post I created using Postman in the previous entry.
At this point we had:
- An Angular admin UI
- Authentication through Entra
- Authorization through the
Blog.AdminAPI scope - CORS allowing the admin UI to communicate with the API
- Blog posts being loaded directly from the API
Locally, everything was working.
Now we needed somewhere to put it.
Deploying to Azure
For hosting, I decided to use Azure App Service.
This application is going to be used pretty sparingly and is essentially an internal admin application for the blog, so there isn’t much reason to build out an elaborate hosting architecture.
For now, I’m using the Free SKU.
This isn’t meant to be a highly available production workload serving thousands of users. It’s an admin application that will probably have two users. Keeping the architecture proportional to the problem is more important to me than making the deployment look sophisticated.
Alongside App Service, we’ll also be using Azure Key Vault.
Moving Secrets into Key Vault
For local development, I use .NET User Secrets extensively.
User Secrets give me a local configuration provider for sensitive values without putting those values into appsettings.json or committing them into source control.
For example, this is where I store the Cosmos DB connection string required by Orbital.
That works great locally, but it doesn’t solve the same problem once the application is deployed to Azure.
That’s where Key Vault comes in.
Instead of keeping sensitive configuration directly inside the application configuration, we can store the secret in Key Vault and allow the application to retrieve it at runtime.
I already have a similar implementation in Trakr, so once again I used an existing implementation as a reference rather than asking Codex to invent a new approach.
let's implement key vault.
check trakr to see how it's done there, and give suggestions on how to make it better if there's room for improvement.
only adjustment made was an environment check - the rest is pretty much the same
The application can use its Azure identity to access Key Vault, which also means I don’t need to introduce another credential just to retrieve the Cosmos DB credential.
That’s an important part of the setup for me: secrets should live outside the application, but accessing the secret shouldn’t require adding another secret.
Setting Up CI/CD
While Codex toiled away at my simple Key Vault request, I started creating the App Services and the Azure DevOps pipelines for both the API and the UI.
While setting up the API pipeline, I realized that I was doing something I’ve done several times before.
I’ve built a few applications using Azure Pipelines at this point, including a small CRM, an inventory management application, Trakr, and now the BPE Blog platform.
Most of those .NET pipelines look pretty similar:
- Authenticate with NuGet
- Restore packages
- Build the application
- Run the tests
- Build the Docker image
- Push the image to Azure Container Registry
- Deploy it
Historically, I’ve more or less copied the YAML from project to project and modified what I needed.
It works, but pipeline templates are obviously a better way of handling this duplication, and they’re something I hadn’t really dipped my toes into yet.
This seemed like the perfect opportunity.
Here’s the resulting template:
parameters:
- name: vmImage
type: string
default: ubuntu-latest
- name: buildConfiguration
type: string
default: Release
- name: buildProjects
type: string
default: "**/*.csproj"
- name: testProjects
type: string
default: "**/*.Tests.csproj"
- name: nugetConfigPath
type: string
default: ""
- name: containerRegistryServiceConnection
type: string
- name: containerImageRepository
type: string
- name: dockerFilePath
type: string
- name: dockerBuildContext
type: string
default: "$(Build.SourcesDirectory)"
- name: dockerBuildArguments
type: string
default: ""
- name: dockerTags
type: string
default: "$(Build.BuildId)"
stages:
- stage: BuildAndTest
displayName: Build and Test
jobs:
- job: BuildAndTest
displayName: Build and Test
pool:
vmImage: ${{ parameters.vmImage }}
steps:
- task: NuGetAuthenticate@1
displayName: Authenticate NuGet feeds
- task: DotNetCoreCLI@2
displayName: Restore NuGet packages
inputs:
command: restore
projects: ${{ parameters.buildProjects }}
${{ if ne(parameters.nugetConfigPath, '') }}:
feedsToUse: config
nugetConfigPath: ${{ parameters.nugetConfigPath }}
- task: DotNetCoreCLI@2
displayName: Build projects
inputs:
command: build
projects: ${{ parameters.buildProjects }}
arguments: >-
--configuration ${{ parameters.buildConfiguration }}
--no-restore
- task: DotNetCoreCLI@2
displayName: Run unit tests
inputs:
command: test
projects: ${{ parameters.testProjects }}
arguments: >-
--configuration ${{ parameters.buildConfiguration }}
--no-build
- stage: Docker
displayName: Build and Push Docker Image
dependsOn: BuildAndTest
condition: succeeded()
jobs:
- job: BuildAndPush
displayName: Build and Push Docker Image
pool:
vmImage: ${{ parameters.vmImage }}
steps:
- task: NuGetAuthenticate@1
displayName: Authenticate NuGet feeds
- task: Docker@2
displayName: Build Docker image
inputs:
command: build
containerRegistry: ${{ parameters.containerRegistryServiceConnection }}
repository: ${{ parameters.containerImageRepository }}
Dockerfile: ${{ parameters.dockerFilePath }}
buildContext: ${{ parameters.dockerBuildContext }}
tags: ${{ parameters.dockerTags }}
${{ if ne(parameters.dockerBuildArguments, '') }}:
arguments: ${{ parameters.dockerBuildArguments }}
env:
DOCKER_BUILDKIT: 1
- task: Docker@2
displayName: Push Docker image
inputs:
command: push
containerRegistry: ${{ parameters.containerRegistryServiceConnection }}
repository: ${{ parameters.containerImageRepository }}
tags: ${{ parameters.dockerTags }}
The biggest change here is the optional nugetConfigPath.
Trakr uses my bpe-common NuGet package hosted through Azure DevOps, so its pipeline needs to authenticate against that feed and restore packages using a custom NuGet configuration.
The BPE Blog API doesn’t have that restriction. Everything it consumes is available through the public NuGet feed.
By making the NuGet configuration optional, the same template works for both types of applications without forcing either one to know about configuration it doesn’t need.
It’s a small change, but this is exactly the kind of duplication templates are supposed to eliminate.
How Should the UI Talk to the API?
Once the applications were ready to deploy, I briefly considered a few ways of exposing communication between the UI and the API.
The options I considered were:
- Keep the services private and expose them through something like a gateway or Azure Front Door.
- Define custom domain names for each service and use strict CORS rules, for example
blog.mydomain.comandblog-api.mydomain.com. - Use the App Service URLs Azure already gives me.
I went with option three.
Azure already provides public HTTPS endpoints for App Service:
blog-admin-ui-h4d9awdaczdmcefd.eastus2-01.azurewebsites.net
bpe-blog-api-a8fbd6gweydqbucd.eastus2-01.azurewebsites.net
For an internal admin application with two users, adding Front Door, a gateway, or even custom domains doesn’t really give me much capability that I need right now.
It would mostly give me a prettier deployment.
Trakr is where I tend to experiment with more sophisticated deployment architectures. For the BPE Blog platform, I’m intentionally trying to use the simplest Azure architecture that solves the current problem.
If the requirements change later, the architecture can change with them.
Production Configuration
With the services deployed, I needed to update the configuration so they could communicate in Azure.
let's update the production environment settings for the API and UI
- Add CORS for the UI URL from a configuration setting
- Add the API URL in the UI directly
There was one small hiccup here.
Codex interpreted “production environment settings” by creating an appsettings.Production.json file.
That would work, but it wasn’t how I wanted configuration structured in this application, so I removed the file and moved the setting into the base appsettings.json.
This is also a good example of something I think is important when working with coding agents.
Codex can generate a solution very quickly, but that doesn’t mean the first solution needs to become part of your architecture.
The generated code still needs to conform to the application’s design — not the other way around.
After updating the configuration and adding the appropriate redirect URLs to the Entra app registrations, everything worked swimmingly.
We now have:
- An Angular admin application
- An ASP.NET Core API
- Entra authentication and authorization
- Azure Key Vault for secrets
- Azure DevOps CI/CD pipelines
- Reusable pipeline templates
- Docker images deployed through Azure Container Registry
- Both applications running in Azure App Service
At this point, the project is starting to look less like an API experiment and more like an actual platform.
What’s Next?
So that’s the UI and deployment handled.
The next step is where the project starts getting a little more interesting: editing and publishing.
Right now, creating and editing posts only affects the data stored by the Blog API. The actual BPE website is still an Astro site built from Markdown files stored in Git.
Publishing a post means bridging those two worlds.
The next phase will involve generating the Markdown document and using the Azure DevOps API to push Git changes into the website repository, which will trigger the existing deployment pipeline and publish the post.
That’s ultimately the part that turns this from another CRUD admin application into the blogging platform I originally set out to build.