Repository navigation
Closed
Milestone
Description
Corresponding PR with the WIP: #1547
The Azure support PR (#1426) gave us a good push forward for getting Azure in. However it's a bit outdated. I took a deep dive today and here's what I think we should change:
How it works:
Click here to see how the PRed implementation works.
Todo:
- Add README.md files to corresponding plugins
- Add docs
- Move
disabledproperty to event (rather than having it inside the function under theazurescope) - Update function compilation so that the new service bound runtime is used (Add service bound runtime functionality #1536)
- Separate compile steps into separate plugins
- The PR is using a single compile plugin with
HttpTriggerandTimerTriggerbuild functions inlib. We should move those two into separate plugins to be consistent with aws plugins.
- The PR is using a single compile plugin with
- Don't retry to create the resource group on errors
- The PR retries creating the resource group if an error happened. This could lead to a circular/infinite bug that is hard to track. We should instead let the user know what caused the resource group creation to fail.
- Get Azure credentials from serverless variables
- The PR gets the Azure username/password creds from env vars. We should also get it from serverless stage variables to allow users to have different account for each stage just like we're doing with AWS
- Use new templating mechanism / Organize templates by provider
- This PR introduces the default
azure-arm.jsontemplate file (this should be moved inside the plugin like we did with AWS). We should organize the templates directory by provider to keep each provider default resources file separate.
- This PR introduces the default
- Remove dependency on Azure CLI
- This PR depends on the Azure CLI and deploys resources by spawning a command to that CLI. We should instead use the SDK if possible, or the ARM Rest API (might be complex to implement though)
- Remove the Azure utils dir/files
- This PR includes a utils dir/files specific to Azure. To stay consistent with AWS plugins, we'll either move that logic into an Azure specific wrapper, or inside the plugins logic.
- Validate input
- This PR lacks input validation. Add it.
- Update unit tests
- Based on all these changes, we'll need to update all the unit tests
- Use new
packageplugin- Use the new package plugin instead of the own zipping functionality (Add package plugin #1494)
- Fix typos / code cleanup so that it follows the patterns which were also applied in the AWS plugins
- Add simple and nested event source syntax
Done:
- Change
http_endpointtohttp- The PR still references the HTTP event as
http_endpoint. To keep it simple and consistent with AWS, we'll change the key to behttp
- The PR still references the HTTP event as
- Update plugins to use new
providerproperty - Change
resourcesobject to reflect provider per service- The PR still references the
resources.azureobject. We should remove theazuresub property.
- The PR still references the
- Rename
scheduled_triggertotimerevent - Change
eventsobject to reflect provider per service- The PR still references the
events.azureobject. We should remove theazuresub property.
- The PR still references the
Thoughts...? cc @flomotlik @pmuens @ac360
Reacted by Philipp Muens
Metadata
Metadata
Labels
No labels
Activity
pmuens commentedon Jul 6, 2016
Thanks for looking into it!
Good idea to keep track of all the steps which should be done 👍 .
I've added the "Use new
packageplugin" step and updated it so that those bullet points are all checklist items.pmuens commentedon Jul 8, 2016
URL to get to functions dashboard:
http://functions.azure.com
Available regions:
Triggers
Package deployment:
Languages
Features
Random notes:
pmuens commentedon Jul 13, 2016
@eahefnawy @flomotlik FYI:
Just looked through the code and created a list how everything works in plain english:
How Azure deployment works (the version of the PR).
compilepluginfunctionsproperty onthis.serverless.service.resource.azureso that we havethis.serverless.service.resource.azure.functions(this will be used to generatefunction.jsonfiles for the deployment later on)httportimerevent (create corresponding JSONs for this events)this.serverless.service.resource.azure.functionsfoowe’ll get this:this.serverless.service.resources.azure.functions[foo] = correspondingTriggerJSON;deployplugindeploy:initializeResourcesazure-arm.jsontemplate from the templates directorythis.serverless.service.resources.azurethis.serverless.service.resources.azure(all the values which were attached to theresources.azuresection will be replaced with the whole, filled out template)before:deploy:createProviderStacksdeploy:createProviderStacksdeploy:deploythis.serverless.service.resources.azure(remember that it’s the whole, pre filled template)function.json(the JSON is the value stored atthis.serverless.service.resources.azure.functions['functionName']) file and include it in the functions .zip fileinvokepluginremoveplugineahefnawy commentedon Jul 14, 2016
@flomotlik @pmuens one caveat about Azure Functions is that it doesn't have a
handlerconcept. Instead, each function is a folder with anindex.jsfile that exports a single function. That's how Azure imports the function code.That means that the exported function ("the handler") will always be in the root of the package...which means functions won't be able to reuse common code because anything outside of that root/folder/package will be excluded (not part of the function).
And because there can only be a single
index.jsfile (that exports a single function) in a folder, we can't reuse the same zip file for all functions like we're doing with AWS because each zip will have a differentindex.jscode in the root based one the function. So we have to deploy each function zip individually.I'm trying to think of a directory structure for an
azure-nodejsservice, and here's what I came up with:Option A
This is the most straightforward directory structure.
FunctionA&FunctionBare completely isolated and won't share code. On deployment, the framework will generate afunction.jsonfile inside each of the functions folder root based on the data inserverless.yaml(this file is required by Azure) and then the framework will generate 2 zip files: theFunctionA&FunctionBfolders, and will push them to Azure.This seems simple to implement, but it's a lot of boilerplate. This is how Azure recommends it in their docs.
Option B
On deployment, the framework generates the required
index.jsin the root of the service for each function by copying the relevant handler fromhandlers.jsand then zip the entire service and deploy it to Azure. Remember, that must happen for each Function since the zip will always be different because we're generating a differentindex.jsfile for each function. Plus of course thefunction.jsonmentioned above. This option looks a lot like our current AWS implementation, and it has the advantage of code reuse between functions, but it introduces some issues:index.jsfile is generated in the root. Will be really slow.handlers.jsfile will always has to be in the root of the service, because we will generate theindex.jsfile in the root of the service, and the location ofhandler.jsandindex.jsshould match otherwise anyrequiresin the handler won't work. We also have no way to "point" to a certain handler with Azure since Azure has no concept of handlers to begin with.I personally prefer option A because:
handlerproperty inserverless.yaml. After our transition to a provider per service implementation, I think each provider service should work the same way the provider is expecting it to work. Users can then make explicit decisions on which provider to choose based on that provider UX.index.jsfile for each runtime/language. Option A simply takes whatever the user has.@flomotlik @pmuens and everyone else, any thoughts...?