Skip to content

Azure CLI script to create Azure Blob Storage together with Azure Function app, deploy code from local Git repo to the Function and register Azure Event Grid action

License

Notifications You must be signed in to change notification settings

kravchenya/azure-cli-funcapp-evengrid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

azure-cli-funcapp-evengrid

Azure CLI sample with Blob Storage, Azure Function and Event Grid

This repository contains a sample azure cli bash script and .NET Core Azure Function. The script creates a Blob Storage with a Container, a Storage Account for Azure Function, Azure Function itself, deploys code from local Git repository to it, and finally registers event grid action (whenever there any changes to blob storage's container done, an Azure Function is invoked).

Prerequisites

In order to get everything running, you would need to install at least

  • Azure CLI to you local machine
  • Git
  • (optionally only for Windows OS) You need to use POSIX-compatible runtime environment (more details are provided below)

Notes

While working on this script I experienced several issues. I mention all of them with possible solutions below

  • You may need to enable Microsoft.EventGrid in your Azure subscription. More details how to do it you can find via link

  • While using Windows as my main OS in a bundle with Git Bash, I saw stange behaviou, which I believe roots to Git Bash. The problem was that the path with installed Git was concatenated with az components specific path. Everything together looked like "C:/Program Files/Git/subscriptions/XXXX-XXXX-XXXX-XXXX/resourceGroups/YYYY/providers/Microsoft.Storage/storageAccounts/ZZZZ/providers/Microsoft.EventGrid/eventSubscriptions/WWWW?api-version=2020-04-01-preview" and led to errors from az. This behaviour was described alredy in this issue report. A possible solution could be a switch to PowerShell script. In my case I gave a try to another runtime environment capable to execute bash script on Windows machines - Cygwin. The solution let me proceed, however brought other glitches later

    • First I had to replace EOL in a script file. F.e. you can read how to do it in Notepad++

    • The next issue was that Cygwin added carriage return symbol (%0D) to variables, which again led to errors from az. How resolve this pitfall you can read here

  • While trying it out many time the same script in a sequence, I had to delete a remote link from my repository. How to do, one can read in this document

  • When I started to write this script, I had to decide, whether to use a local Git repository or a remote one. I chose the first one. However if you tend to the second one, you may need to do some extra configuration in Azure and in GitHub. More details about it you can find here

  • And at the end. Very useful link. While working on my script I used these azure cli samples a lot and believe they are very handy for further scripting.

About

Azure CLI script to create Azure Blob Storage together with Azure Function app, deploy code from local Git repo to the Function and register Azure Event Grid action

Topics

Resources

License

Stars

Watchers

Forks