Skip to content

Instantly share code, notes, and snippets.

@olafloogman
Last active November 2, 2018 05:39
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 olafloogman/fe164070b91eab7489795c07fbceb446 to your computer and use it in GitHub Desktop.
Save olafloogman/fe164070b91eab7489795c07fbceb446 to your computer and use it in GitHub Desktop.
Param(
[string] $AppName
)
$ResourceGroupName = $AppName + "-rg"
$FunctionName = $AppName + "-func"
$needPsLogin = $true
Try
{
$content = Get-AzureRmContext
if ($content)
{
$needPsLogin = ([string]::IsNullOrEmpty($content.Account))
}
}
Catch
{
if ($_ -like "*Login-AzureRmAccount to login*")
{
$needPsLogin = $true
}
else
{
throw
}
}
if ($needPsLogin)
{
Login-AzureRmAccount
}
.\FunctionAppProxy\Deploy-AzureResourceGroup.ps1 -ResourceGroupName $ResourceGroupName
Compress-Archive -Path .\AppContents\* -DestinationPath functionapp.zip -Force
$needAzLogin = $true
Try
{
$content = az account show
if ($content)
{
$needAzLogin = ([string]::IsNullOrEmpty($content))
}
}
Catch
{
if ($_ -like "*Please run 'az login' to setup account")
{
$needAzLogin = $true
}
else
{
throw
}
}
if ($needAzLogin)
{
az login
}
az functionapp deployment source config-zip --src functionapp.zip --name $functionName --resource-group $ResourceGroupName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment