immutabl
immutabl

Reputation: 6903

DIY CDN: Deploying from Bitbucket to Azure Storoage

I'm trying to set up continuous deployment from a Bitbucket repo to an Azure CDN. The usage scenario is that front-end developers will commit static assets (js, images, css stylesheets etc.) to their Bitbucket repo and trigger an automatic release to an Azure blob storage instance.

I've setup the CDN and its blob storage service endpoint and can serve test files from it successfully. What I can't figure out is how to connect Bitbucket to it. I have set up a Pipeline with a stock skeleton script, but now I'm stuck and need some pointers.

Also, the blob container is completely unstructured - is there some way of imposing a folder structure on it? The only workaround I can think of so far is to have separate containers (e.g. for css, js, img) but this seems like over-engineering when simple directories would seem to suffice. Can anyone please assist?

Upvotes: 1

Views: 813

Answers (1)

Bruce Chen
Bruce Chen

Reputation: 18465

I've setup the CDN and its blob storage service endpoint and can serve test files from it successfully. What I can't figure out is how to connect Bitbucket to it. I have set up a Pipeline with a stock skeleton script, but now I'm stuck and need some pointers.

I have checked with Bitbucket Pipelines and this tutorial about deploying from Bitbucket Pipelines to Azure Web Apps and this pipeline2azure about publishing a web application from Bitbucket Pipelines to an Azure Web App via FTP deployment. For Azure blob storage, I assumed that you need to leverage Manage webhooks to make requests to your server with the Event Payloads (e.g. Push, Updated, etc.) in your repository, then you get to determine what files were added, modified, or deleted, then use Bitbucket Cloud REST APIs to retrieve the files and leverage Azure Blob storage client SDK or REST API for uploading files to your blob storage.

As I known, Azure CDN supports Origin type (Storage, Cloud service, Web App, Custom origin). Per my understanding, for a simple way, you could leverage Continuous Deployment to Azure App Service with your BitBucket repository, then point your Azure CDN to the Web App. Additionally, you could leverage KUDU or ftp tool (e.g. FileZilla) to manage your static files.

Upvotes: 1

Related Questions