Home How to deploy an ASP.net application in IIS server in Azure Windows VM using Powershell Script?
Reply: 0

How to deploy an ASP.net application in IIS server in Azure Windows VM using Powershell Script?

user52808
1#
user52808 Published in September 19, 2018, 7:27 pm

I have created a Windows Server 2012 R2 VM using azure ARM template. I have successfully configured IIS on it. I have to deploy ASP .Net web sites to the IIS on the VM. Now I am facing problem how to deploy the application in IIS server using powershell script.

I am using the below script to download the application from Azure blob storage and saving in "C:\WindowsAzure\WebApplication.zip" folder. The script is working till downloading and copying to "C:\WindowsAzure\WebApplication.zip" folder. But it's not deploying to "C:\inetpub\wwwroot" folder.

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

            }

        }

     }

}

Please give me some idea.

share|improve this question
  • What's the error message you are getting? Is it showing nothing? – Jack Zeng Mar 30 '16 at 5:06
  • When I am accessing my webapplication like (http://<public IP/ DNS name> /WebApplication) it's showing "No directory found". I logged in to that VM and checked there is no webapplication folder under inetpub\wwwroot directory. So, Please give me some idea, that how can I deploy my ASP.net application in IIS server using script. – Sandhyarani Sahoo Mar 30 '16 at 5:52
  • Have your tried to deploy your web app with Visual Studio? Get more information in Creating a virtual machine for a web application with Visual Studio. I am not sure if you have your VM properly configured. – Jack Zeng Mar 30 '16 at 6:33
  • Yes, My application is working fine in Visual Studio. Whatever script I am using, I have taken that from Github. All the script is working properly for one particular application mentioned in Github. But when I am deploying my application it's not working. I have tried with 2-3 application from internet, still it's not working. I am using the below github URL for my application deployment in VM. (github.com/Azure/azure-quickstart-templates/tree/master/…). – Sandhyarani Sahoo Mar 30 '16 at 7:45
  • I know your app works properly in Visual Studio. What I am asking is that whether you have tried to deploy the app to your VM in Visual Studio, just like deploying the app to Azure App Service. If you want to deploy a web app to an Azure VM, you need to enable IIS and Web Deploy. If you created your VM through Visual Studio, you can do that while creating the VM. – Jack Zeng Mar 30 '16 at 7:46

active oldest votes

Your Answer

StackExchange.ifUsing("editor", function () { StackExchange.using("externalEditor", function () { StackExchange.using("snippets", function () { StackExchange.snippets.init(); }); }); }, "code-snippets"); StackExchange.ready(function() { var channelOptions = { tags: "".split(" "), id: "1" }; initTagRenderer("".split(" "), "".split(" "), channelOptions); StackExchange.using("externalEditor", function() { // Have to fire editor after snippets, if snippets enabled if (StackExchange.settings.snippets.snippetsEnabled) { StackExchange.using("snippets", function() { createEditor(); }); } else { createEditor(); } }); function createEditor() { StackExchange.prepareEditor({ heartbeatType: 'answer', convertImagesToLinks: true, noModals: false, showLowRepImageUploadWarning: true, reputationToPostImages: 10, bindNavPrevention: true, postfix: "", onDemand: true, discardSelector: ".discard-answer" ,immediatelyShowMarkdownHelp:true }); } });
 
StackExchange.ready( function () { StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f36281514%2fhow-to-deploy-an-asp-net-application-in-iis-server-in-azure-windows-vm-using-pow%23new-answer', 'question_page'); } );

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged asp.net powershell azure dsc or ask your own question.

StackExchange.ready(function(){$.get('/posts/36281514/ivc/c675');});
StackExchange.ready(function () { StackExchange.responsiveness.addSwitcher(); }) (function(i, s, o, g, r, a, m) { i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function() { (i[r].q = i[r].q || []).push(arguments) }, i[r].l = 1 * new Date(); a = s.createElement(o), m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m); })(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga'); StackExchange.ready(function () { StackExchange.ga.init({ sendTitles: true, tracker: window.ga, trackingCodes: [ 'UA-108242619-1' ] }); StackExchange.ga.setDimension('dimension2', '|asp.net|powershell|azure|dsc|'); StackExchange.ga.setDimension('dimension3', 'Questions/Show'); StackExchange.ga.trackPageView(); }); /**/ var _qevents = _qevents || [], _comscore = _comscore || []; (function() { var ssl = 'https:' == document.location.protocol, s = document.getElementsByTagName('script')[0], qc = document.createElement('script'); qc.async = true; qc.src = (ssl ? 'https://secure' : 'http://edge') + '.quantserve.com/quant.js'; s.parentNode.insertBefore(qc, s); _qevents.push({ qacct: "p-c1rF4kxgLUzNc" }); /**/ var sc = document.createElement('script'); sc.async = true; sc.src = (ssl ? 'https://sb' : 'http://b') + '.scorecardresearch.com/beacon.js'; s.parentNode.insertBefore(sc, s); _comscore.push({ c1: "2", c2: "17440561" }); })();
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.324353 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO