Access Azure/Kudu Variables from PowerShell Post Deployment Action Hook

I'm deploying Azure app services with Git continuous deployment and using post deployment action hooks to log the deployment to a Slack channel. My action hooks are written as PowerShell scripts.

From within my PowerShell scripts how do I access Azure or Kudu environmental variables or app settings? It's clear how to do this via deploy.cmd but I'm having no luck from PowerShell.

Ideally I'd like to be able to access things like:

  • Azure app service name
  • Deployment slot name
  • Deployment source/target paths
  • App settings and/or connection strings

  • Ok figured this out, apparently all of the Azure environment variables available within your website app service are available to PowerShell scripts running as post deployment actions.

    To get the site name within PowerShell:

    $siteName = [environment]::GetEnvironmentVariable("WEBSITE_SITE_NAME");
    

    In addition to site name there are dozens of other Azure environment variables plus your app settings and connection strings.

    链接地址: http://www.djcxy.com/p/68496.html

    上一篇: 使用Azure保留的IP交换部署插槽

    下一篇: 从PowerShell后部署操作钩子访问Azure / Kudu变量