Skip to content

Instantly share code, notes, and snippets.

@mjul
Created August 14, 2018 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjul/600f8f4706bedc8e5c066a4a94f13e71 to your computer and use it in GitHub Desktop.
Save mjul/600f8f4706bedc8e5c066a4a94f13e71 to your computer and use it in GitHub Desktop.
Install the latest release of the Azure Functions item and project templates for dotnet new
# Install the latest release of the Azure item and project templates:
#
# See [Azure Functions Templates wiki](https://github.com/Azure/azure-functions-templates/wiki/Using-the-templates-directly-via-dotnet-new)
# See [Issue 721](https://github.com/Azure/azure-functions-templates/issues/721)
$feed = Invoke-WebRequest https://functionscdn.azureedge.net/public/cli-feed-v3.json | ConvertFrom-Json
$release = $feed.tags.v2.release
foreach ($t in "itemTemplates", "projectTemplates") {
$uri = $feed.releases."$release"."$t"
$headers = Invoke-WebRequest $uri -Method Head
$name = $headers.Headers."Content-Disposition" -replace 'filename=(.*)', '$1'
Write-Output "Installing $name ..."
$tmpFile = [System.IO.Path]::GetTempFileName();
Invoke-WebRequest $uri -OutFile $tmpFile
dotnet new -i $tmpFile | Out-Null
Remove-Item $tmpFile
}
# To uninstall:
#
# dotnet new -u Azure.Functions.Templates
# dotnet new -u Microsoft.AzureFunctions.ProjectTemplates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment