ACG Azure Resume Challenge

ACG Azure Resume Challenge

I'm a firm believer that we learn when we are pushed outside of our comfort zone. I'm an IT veteran and I became fascinated with Cloud Technology. Learning about Serverless technology was a revelation to me. Enter the ACG Azure Resume Challenge (thank you, Gwyn, Gwyneth Peña S.). This is going to be fun, last time I seriously coded anything was in VB6 yikes!!

Overview: image.png

Testing Out HTTP Trigger Function If you get an error running "func host start" stating it's not recognizing func as a command of any kind, please re-install Azure Function Core Tools with VS Code closed. bit.ly/3vB3Lj2

Passed a string (very exciting!) image.png

Executed yay! image.png

Binding to CosmosDB with Microsoft.Azure.Cosmos 3.19.0

image.png

Making sure we match (very important or you won't have a good time)

image.png

CosmosDB binding code: (This was by far the most difficult part for me, as I had to learn C# as I went along)

[CosmosDB(databaseName:"azureresumedb", collectionName: "counter", ConnectionStringSetting = "AzureResumeConnectionString", Id = "1", PartitionKey = "1")] Counter counter,

[CosmosDB(databaseName:"azureresumedb", collectionName: "counter", ConnectionStringSetting = "AzureResumeConnectionString", Id = "1", PartitionKey = "1")] out Counter upcounter,

// Very Important when adding the connection string to local.settings.json, make sure you copy the PRIMARY CONNECTION STRING, not the PRIMARY KEY. You will save yourself a lot of tail chasing. Don't ask me how I know this // Rant Over...

Ready to deploy the Function to Azure. Having issues with the fact that it's cloned from a different machine (my suspicion) and VS Code doesn't see it as a project. There is one workaround, create a new function project and surgically replace folder structure and files. I'm going to try and deploy as Azure Function right from the folder. Encountered an error for the deployment path. Fix is to modify Workspaces Azure Functions:Deploy Subpath with the path you are attempting to deploy from.

Great Success is running locally again, now as a project. Just had a small issue with references so don't forget to modify your references in *.csproj kids.

After much re-configuration on the local side, I finally deployed to Azure successfully. The function is running in the Cloud! Woohoo!! I can't stress enough don't forget to turn on CORS (Cross-Origin Resource Sharing) AND functionAPI url :)

While Deploying static web to blob storage got an error: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature The root cause was that the folder containing my static website, was outside of the project folder.

Another bump in the road: Access to fetch at 'https://acgazureresume.documents.azure.com/;AccountKey=xxxxxxxx;' from origin has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. Fix was (and don't laugh) inserted the CosmosDB connection string into const functionApi = instead of the function URL. You live and you learn. But the not all was wasted as I got to take everything apart and put it all back together on the fly, learned a TON.

CDN Part!

I will even venture to say this is the easy part :) Added my endpoint and mapped two custom domains cloudboundboris.com and cloudboundboris.me because why not? they were very cheap ;) This also means I will have to update CORS with both domains. -Capt Obvious

Ok, one small gotcha: the CDN domain verification seems to be taking a while and may take up to 48 hours. image.png

CI/CD Part! This is really awesome stuff!

Tested workflows successfully, had some issues along the way as my folder structure is a bit more nested, but I prevailed. CDN Purge took its sweet time image.png

Overall what an amazing learning experience, there are a few more things I will change over the coming days it's been an insane 48 hour push to complete this challenge. One thing I will change is implementing the Azure Key Vault instead of pasting the connection string directly. Definitely tidy up the CI/CD functionality.

Few takeaways are: Paying attention to details but I suppose that went out of the window when coming down to the wire and rushing a bit. But for example, pasting azure secret in GitHub you can't forget the {} also :)

The learning experience and knowledge I gained from this challenge are priceless as I look forward to taking my AZ-204 Exam a lot of what's covered in this challenge is actually in that exam. This is a great learning model going full hands-on and making mistakes, taking everything apart, and fixing real problems. Thank you acloudguru.com and Gwyneth Peña S..

Carrying on. Stay Tuned