I’ve been using Azurite to simulate Azure storage for my development. If you’re not familiar with it, Azurite is a local storage emulator for Azure Storage, and you can read my other post about how i’ve set up my devcontainer configuration to run Azurite as a service container. As my deployed code is using an Azure Managed Identity, I wanted ensure my development environment was consistent with this and also uses Azure DefaultAzureCredential credential provider class. In this post, i will talk through the steps required to switch from using a connection string (with a well-known account and key) to… Continue reading →
When developing with Azure Storage, it can significantly speed up your development process if you can use a local development environment, rather than constantly connecting directly to storage in Azure itself. This is where Azurite comes in – Azurite is a local storage emulator for Azure Storage, mimicing blob/container, queue and table storage. While there are lots of ways to get it running (e.g. from binary, manually using Docker etc.), I wanted to set it up as a service container in my devcontainer configuration which provides a few benefits: This guide provides a basic outline for setting up Azurite as… Continue reading →
In Pulumi, when calling pulumi_azure_native.storage.list_storage_account_service_sas_output() to generate a SAS, you pass the required permissions to the permissions: Input[str | Permissions | None] parameter. pulumi_azure_native.storage.Permissions is an enum, offering simple selections (R, L etc.): But you can also pass a string of permissions, any of R, L, D, W, C, A, or P, depending on the actions you want to allow for the SAS. This allows you to specify permissions for reading (R), listing (L), deleting (D), writing (W), creating (C), adding (A), or processing (P) blobs within the container, such as permissions=”RWL”: Continue reading →
Another note for myself. I wanted to use this to give my app access to the entire account. I thought they would be a property of pulumi_azure_native.storage.StorageAccount but they’re not. Instead you need to call pulumi_azure_native.storage.list_storage_account_keys(). Continue reading →
In a storage account, you can create a SAS scoped to a specific container, however, that SAS does not have permission to execute BlobClient.exists() as this requires at least list privileges on the parent object (e.g. the account), and when you try to perform the check, you’ll get this error: Note that this is an HttpResponseError, not a ClientAuthenticationError (which is actually a more specific error which extends HttpResponseError), so you need to interrogate the specific response code, although note that if the container client does not exist, you might also get a ClientAuthenticationError with this message: As a workaround,… Continue reading →
This post is mainly a reminder to myself, because i’ve made the same mistake a few times in different projects. How and why to deploy Azure functions from a package When using Azure Functions, you can simplify deployment and maintenance of your function by deploying from a package file rather than directly in to the function. This also has the benefit of reducing cold start times, particularly where there are a large number of dependencies. To deploy from a package (without using the Azure deployment tools), you: The WEBSITE_RUN_FROM_PACKAGE setting can either be a 1 if you’ve deployed your code… Continue reading →
Another post which is more to remind me than anything else. When creating an Azure Function in Pulumi, you may get the following error: Cannot modify this site because another operation is in progress After a bit of digging, i found this issue on the Pulumi repo, which points to a page on the Azure Functions wiki where they say: If you run in a dedicated mode, you need to turn on the Always On setting for your Function App to run properly … When running in a Consumption Plan or Premium Plan you should not enable Always On. The Always On setting for… Continue reading →
When uploading images to WordPress, you may get this error. There are plenty of blogs online offering solutions, but they only apply to self-hosted instances – mine is hosted on just-what-i-find.onyx-sites.io/. The error is a little pop up with the text The response is not a valid JSON response at the bottom of the screen when you try and upload an image: Looking in the developer tools console on the browser shows one of two error messages: Failed to load resource: the server responded with a status of 403 () for URL /wp-json/wp/v2/media or POST https://atomic-temporary-181991729.wpcomstaging.com/wp-json/wp/v2/media?_locale=user 403 (Forbidden) I have… Continue reading →
In a previous post, I created a Barman backup script to back up PostgreSQL running in an VM to AWS S3. If you host your PostgreSQL server in Azure, this can get expensive quickly because you pay egress bandwidth fees to Microsoft. In this article, i’ll show you how to use Azure Blob storage instead. Step 1: Install Barman, barman-cli-cloud, snappy etc. see original article. Step 2: Install Azure CLI instead of AWS S3 CLI Follow the instructions on the Microsoft website. Step 3: Install azure-storage-blob Python package Log in as the postgres user and use pip to install azure-blob-storage:… Continue reading →
In my previous post, I showed how to automate backups of a PostgreSQL database to S3 using Barman and barman-cloud-backup. Step 1: verify hardware architecture and PostgreSQL version For a successful restore, Barman requires that the hardware architecture and PostgreSQL version are both identical. You can verify these with some simple terminal commands: Run these on both the source and target. Obviously, if you dont have the source any more (which is why you’re restoring), you’ll need to make some assumptions… Step 2: Install Barman, barman-cli-cloud, AWS CLI, python-snappy Follow the instructions in steps 5-10 of in my original article.… Continue reading →
I’m rob. I spend my time exploring the world, playing board games with my family, solving complex technical problems, and learning new things. At work, I lead a team of solution architects designing and building complex realtime trading systems. Sometimes i write about things here, or code them on GitHub. I believe a few things that guide what I do and how I do it: