New Powershell command line goodies for Windows Azure at #bldwin | Glenn Block
Note: Please make sure to install Azure SDK 1.8 before installing the SDK. Some customers have ran into issues where the 1.8 SDK is not getting pulled in with our web pi feed.
We just shipped the latest update for our Powershell cmdlets for Windows Azure. It is literally packed with new and useful features which you’ve been asking for! Below is a quick summary of what is new followed by more detail.
- Django Web Role – Create a Python/Django web role!
- Windows Azure Websites (help website) – Create, delete, configure and manage your Windows Azure Websites. This includes the ability to do things like CRUD management of connection strings and app settings, setting number of workers and much more. On the management side you can drill into your deployments, do rollbacks or download the logs.
- Configuring Github deployment – This relates to Websites, but it’s too cool to bury it in the previous bullet. You can now connect your Website to Github all via the command line. This works really seamlessly if you are in an existing local git repo as we extract the info from your remotes. All of this without ever having to open a browser, w00t!
- SQL Database (help sql) – Create and manage SQL Server instances, firewall rules, etc in the cloud!
- Caching (help azurecache) – For PHP and Node developers you can scaffold a cache worker role which uses the new dedicated Azure cache. You can then enable your PHP/Node app running in a web role to talk to the cache using the Memcached driver!
If you are like me and just want to jump in, don’t wait, just go grab the bits now. And if you are like my friend @ayende and won’t use tools until you read the code, no problem, you can git that here and step through line by line
Yes you read it right my friend, DJANGO. In the box you will also find a new cmdlet for scaffolding out a Django Web Role. That adds Python to the growing list of supported stacks.
Speaking of Python, our Python editor team just released the RTM verson of Pytools http://pytools.codeplex.com. It includes a bunch of new stuff including management apis, support for web sites, live debug repl, debug & watch, and more.
Windows Azure Websites
Note: Example apps below are all node.js apps, but you can use Websites for .NET, Node and PHP.
We’ve introduced a comprehensive set of commands for working with your Websites. Just type “help website” and you’ll see.
Below you can see that how I create my website using the New-AzureWebsite cmdlet and enable git based deployment. I then push to my repo and see as expected that because this is a node app, npm kicks off to download my node.js modules.
Github based deployment
In our last release of Windows Azure Websites we enabled you to wire up your Website to Github via the portal so that each time you push to Github, you push to your Website. Well now you can do the same via Powershell! Below you can see creating the same website only this time I specified to use Github which prompts me for my Github credentials.
After entering my credentials, Github is wired up. I then can use the Get-AzureDeployment cmdlet to check if my app has been deployed.
Note: With this release if your remote is using an SSH url, we will prompt you with a list of repos for you to select from. This is a point in time behavior will be fixed shortly to work the same way as we do for https remotes.
Once I have a website created, I can use the convenient Show-AzureWebsite cmdlet.
And voila, my site will open in the browser.
The cmdlets offer you a lot of rich options for configuring your websites, and you can pipe them together for scripting. For example below I am retrieving the list of websites using Get-AzureWebsite and piping the resulting objects into the Remove-AzureWebsite cmdlet which removes all my websites.
One of the really nice features in the Websites portal experience is you can configure “App Settings”. For node developers this information is then surface as environment level variables which can be accessed within you application. It’s very useful for either secure information or environment specific settings. For example imagine I deploy the same site code to a staging website and a production website, I can use settings for storing the DB connection information so that each website connects to the correct server. With this release you can now do this via the CLI!
Below you can see a screenshot showing how I am configuring my app to have a “message” setting.
I have modified my express app to then pull process.env.message for the main text:
I can then retrieve the settings and modify them piping back the results directly using Set-AzureWebsite. The changes are instant.
If you are deploying apps to the cloud then most likely you need a database. In Windows Azure you have many options for hosted databases at your disposal including SQL Server, MySQL and now MongoDB. In this release we’re happy to announce that we’re shipping cmdlets for managing Azure hosted SQL Databases. Just type “help sql” and you’ll see the cmdlets.
With the new cmdlets it is really easy to provision a new SQL server, add firewall rules and create databases
Azure Cache role for node and PHP!
One of the big requests we’ve heard from community was to support using the new Azure Cache from node.js and PHP applications. With this release we’ve now introduced a new set of cmdets for doing just that. You can create a dedicated cache in Worker Role and then wire up Web roles to communicate with that cache using the Memcached protocol. Below you can see how easy it is.
One the cache is wired up, you can then use either the node or PHP memcached driver to talk to it. When you connect to the client, you use the convention ‘localhost_[webrole]’ i.e. ‘localhost_WebRole1’ for the previous example to talk to the cache. Below is a snippet of how to do this in node using the mc module.
And here is how to do it in PHP.
Using the new distributed cache can be a big help for applications that store large amounts of either transient / or lookup data. Currently we only support the dedicated cache, but we are looking to also support the shared in role cache. We could use your feedback though so let us know which models you use (distributed vs shared cache)
Many more goodies to come
This is just the beginning of what will be a wave of new Powershell cmdlets for Azure, things like ServiceBus, Azure Store and much much more.
Go get started by downloading them now
Let us know how you like the new cmdlets and if there are specific areas you’d like to see us invest in.
Spoiler alert: We also just updated our npm package where you will find a bunch of this functionality also in our cross plat cli. Stay tuned as that post is next.
$havefun = Download_the_bits()