Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Powershell脚本在Azure Windows VM的IIS服务器中部署ASP.net应用程序?_Asp.net_Powershell_Azure_Dsc - Fatal编程技术网

如何使用Powershell脚本在Azure Windows VM的IIS服务器中部署ASP.net应用程序?

如何使用Powershell脚本在Azure Windows VM的IIS服务器中部署ASP.net应用程序?,asp.net,powershell,azure,dsc,Asp.net,Powershell,Azure,Dsc,我已经使用azure ARM模板创建了Windows Server 2012 R2虚拟机。我已成功在其上配置IIS。我必须将ASP.Net网站部署到VM上的IIS。现在,我面临着如何使用powershell脚本在IIS服务器中部署应用程序的问题 我正在使用以下脚本从Azure blob存储下载应用程序,并保存在“C:\WindowsAzure\WebApplication.zip”文件夹中。脚本一直工作到下载并复制到“C:\WindowsAzure\WebApplication.zip”文件夹。

我已经使用azure ARM模板创建了Windows Server 2012 R2虚拟机。我已成功在其上配置IIS。我必须将ASP.Net网站部署到VM上的IIS。现在,我面临着如何使用powershell脚本在IIS服务器中部署应用程序的问题

我正在使用以下脚本从Azure blob存储下载应用程序,并保存在“C:\WindowsAzure\WebApplication.zip”文件夹中。脚本一直工作到下载并复制到“C:\WindowsAzure\WebApplication.zip”文件夹。但它没有部署到“C:\inetpub\wwwroot”文件夹


请告诉我一些想法。

您收到的错误消息是什么?它没有显示任何内容吗?当我访问像(http:///webapplication)这样的Web应用程序时,它显示“找不到目录”。我登录到该虚拟机并检查inetpub\wwwroot目录下没有webapplication文件夹。所以,请告诉我一些想法,如何使用脚本在IIS服务器中部署ASP.net应用程序。您是否尝试过使用Visual Studio部署web应用程序?在中获取更多信息。我不确定您是否正确配置了VM。是的,我的应用程序在Visual Studio中运行良好。无论我使用什么脚本,我都是从Github获得的。对于Github中提到的一个特定应用程序,所有脚本都正常工作。但当我部署应用程序时,它不起作用。我试过从互联网上下载2-3个应用程序,但仍然不起作用。我在VM中使用下面的github URL进行应用程序部署。()我知道你的应用程序在Visual Studio中运行正常。我要问的是,您是否已尝试在Visual Studio中将应用程序部署到您的VM,就像将应用程序部署到Azure应用程序服务一样。如果要将web应用部署到Azure VM,则需要启用IIS和web部署。如果您是通过VisualStudio创建VM的,则可以在创建VM时执行此操作。
Configuration Main
{
  param (
  $MachineName,
  $WebDeployPackagePath,
  $UserName,
  $Password
  )

  Node ($MachineName)
  {

     WindowsFeature WebServerRole

        {



            Name = "Web-Server"

            Ensure = "Present"


            }


        WindowsFeature WebAppDev

        {

            Name = "Web-App-Dev"

            Ensure = "Present"


            DependsOn = "[WindowsFeature]WebServerRole"

            }

           WindowsFeature WebAspNet45

        {

            Name = "Web-Asp-Net45"

            Ensure = "Present"

            Source = $Source

            DependsOn = "[WindowsFeature]WebServerRole"

            }

        WindowsFeature WebNetExt35

        {

            Name = "Web-Net-Ext"

            Ensure = "Present"

            DependsOn = "[WindowsFeature]WebServerRole"

            }

           WindowsFeature WebNetExt45

        {

            Name = "Web-Net-Ext45"

            Ensure = "Present"

            DependsOn = "[WindowsFeature]WebServerRole"

            }

          WindowsFeature WebFtpServer
          {
                Name = "Web-Ftp-Server"

            Ensure = "Present"

            DependsOn = "[WindowsFeature]WebServerRole"

          }

          WindowsFeature WebMgmtCompat
          {
            Name = "Web-Mgmt-Compat"

            Ensure = "Present"

            DependsOn = "[WindowsFeature]WebServerRole"

          }

        WindowsFeature WebISAPIExt

        {

            Name = "Web-ISAPI-Ext"

            Ensure = "Present"


            DependsOn = "[WindowsFeature]WebServerRole"

        }

        WindowsFeature WebISAPIFilter

        {

            Name = "Web-ISAPI-Filter"

            Ensure = "Present"


            DependsOn = "[WindowsFeature]WebServerRole"

        }

        WindowsFeature WebLogLibraries

        {

            Name = "Web-Log-Libraries"

            Ensure = "Present"

            DependsOn = "[WindowsFeature]WebServerRole"

        }

        WindowsFeature WebRequestMonitor

        {

            Name = "Web-Request-Monitor"

            Ensure = "Present"

            DependsOn = "[WindowsFeature]WebServerRole"

        }

        WindowsFeature WebMgmtTools

        {

            Name = "Web-Mgmt-Tools"

            Ensure = "Present"

            DependsOn = "[WindowsFeature]WebServerRole"

        }

        WindowsFeature WebMgmtConsole

        {

            Name = "Web-Mgmt-Console"

            Ensure = "Present"

            DependsOn = "[WindowsFeature]WebServerRole"

        }

        WindowsFeature WAS

        {

            Name = "WAS"

            Ensure = "Present"

            DependsOn = "[WindowsFeature]WebServerRole"

        }

        WindowsFeature WASProcessModel

        {

            Name = "WAS-Process-Model"

            Ensure = "Present"

            DependsOn = "[WindowsFeature]WebServerRole"

        }

        WindowsFeature WASNetEnvironment

        {

            Name = "WAS-NET-Environment"

            Ensure = "Present"

            DependsOn = "[WindowsFeature]WebServerRole"

        }

        WindowsFeature WASConfigAPIs

        {

            Name = "WAS-Config-APIs"

            Ensure = "Present"

            DependsOn = "[WindowsFeature]WebServerRole"

        }

   #script block to download WebPI MSI from the Azure storage blob
    Script DownloadWebPIImage
    {
        GetScript = {
            @{
                Result = "WebPIInstall"
            }
        }
        TestScript = {
            Test-Path "C:\WindowsAzure\wpilauncher.exe"
        }
        SetScript ={
            $source = "http://go.microsoft.com/fwlink/?LinkId=255386"
            $destination = "C:\WindowsAzure\wpilauncher.exe"
            Invoke-WebRequest $source -OutFile $destination

        }
    }

    Package WebPi_Installation
    {
        Ensure = "Present"
        Name = "Microsoft Web Platform Installer 5.0"
        Path = "C:\WindowsAzure\wpilauncher.exe"
        ProductId = '4D84C195-86F0-4B34-8FDE-4A17EB41306A'
        Arguments = ''
    }

    Package WebDeploy_Installation
    {
        Ensure = "Present"
        Name = "Microsoft Web Deploy 3.5"
        Path = "$env:ProgramFiles\Microsoft\Web Platform Installer\WebPiCmd-x64.exe"
        ProductId = ''
        #Arguments = "/install /products:ASPNET45,ASPNET_REGIIS_NET4,NETFramework452,NETFramework4Update402,NetFx4,NetFx4Extended-ASPNET45,NetFxExtensibility45,DefaultDocument,DirectoryBrowse,StaticContent,StaticContentCompression,WDeploy  /AcceptEula"
        Arguments = "/install /products:WDeploy  /AcceptEula"
        DependsOn = @("[Package]WebPi_Installation")
    }


    Script DeployWebPackage
    {
            GetScript = {
                @{
                    Result = ""
                }
            }
            TestScript = {
                $false
            }
            SetScript ={

                $WebClient = New-Object -TypeName System.Net.WebClient
                $Destination= "C:\WindowsAzure\WebApplication.zip" 
                $WebClient.DownloadFile($using:WebDeployPackagePath,$destination)
                $Argument = '-source:package="C:\WindowsAzure\WebApplication.zip"' + ' -dest:auto,ComputerName="localhost",'+"username=$using:UserName" +",password=$using:Password"
                $MSDeployPath = (Get-ChildItem "HKLM:\SOFTWARE\Microsoft\IIS Extensions\MSDeploy" | Select -Last 1).GetValue("InstallPath")
                Start-Process "$MSDeployPath\msdeploy.exe" $Argument -Verb runas

            }

        }

     }

}