I cannot upload an ASF package to a remote Azure Image Store. The process fails using the following script at 53.8% with 0/6 replicated files (0/0% complete).
I cannot also publish to a remote cluster using Visual Studio. As I get the following error:
WARNING: Failed to contact Naming Service. Attempting to contact Failover
Are there any alternative ways of pushing up an application? The Azure Service Fabric on Azure experience just isn't working for me and I've wasted days on it.
Thanks in advance!
Powershell deployment script below:
# Variables
$endpoint = 'XXX-asf.australiaeast.cloudapp.azure.com:19000'
$privateThumbprint = 'XXX'
$publicThumbprint = 'XX'
$projectPath = "C:\dev\asf-network-hops\AsfNetworkHops\AsfNetworkHops\AsfNetworkHops.sfproj"
$projectConfiguration = "Debug"
$packagePath = Resolve-Path "$projectPath\..\pkg\$projectConfiguration"
$applicationTypeName = "AsfNetworkHopsType"
$applicationName = "fabric:/AsfNetworkHops"
$imageStoreConnectionString = "fabric:ImageStore"
# Connect
# $conn = Connect-ServiceFabricCluster -ConnectionEndpoint $endpoint `
# -KeepAliveIntervalInSec 10 `
# -X509Credential -ServerCertThumbprint $privateThumbprint `
# -FindType FindByThumbprint -FindValue $publicThumbprint `
# -StoreLocation CurrentUser -StoreName My
$imageStoreConnectionString = ""
$conn = Connect-ServiceFabricCluster -ConnectionEndpoint XXX-asf.australiaeast.cloudapp.azure.com:19000 `
-KeepAliveIntervalInSec 10 `
-X509Credential -ServerCertThumbprint XXX`
-FindType FindByThumbprint -FindValue XXX`
-StoreLocation CurrentUser -StoreName My
if (-not $conn)
{
$conn
throw "Connection error!"
}
# Clean, Compile, & Package
dotnet clean $projectPath /p:Configuration=$projectConfiguration /nologo
dotnet msbuild $projectPath /t:Package /nologo /p:Platform="x64" /p:Configuration=$projectConfiguration /nologo /p:WarningLevel=1
Write-Host "Uploading package $packagePath"
Copy-ServiceFabricApplicationPackage $packagePath -ImageStoreConnectionString $imageStoreConnectionString -ApplicationPackagePathInImageStore $applicationTypeName -ShowProgress -ShowProgressIntervalMilliseconds 500 -TimeoutSec 1000000 -CompressPackage
Related
I have the below step in the Azure pipeline
- task: AzureCLI#2
displayName: get Logic App SAS Token
name: getLogicAppSASToken1
inputs:
azureSubscription: ${{ parameters.serviceAccount }}
scriptType: pscore
scriptLocation: inlineScript
inlineScript: |
$workflowDetails1 = az rest --method post --uri https://management.azure.com/subscriptions/$(SUBSCRIPTION_ID)/resourceGroups/$(RG_LOGIC_APP)/providers/Microsoft.Web/sites/$(LOGIC_APP_NAME)/hostruntime/runtime/webhooks/workflow/api/management/workflows/$(WORKFLOW_NAME1)/triggers/manual/listCallbackUrl?api-version=2018-11-01
$workflowResponse1 = $workflowDetails1 | ConvertFrom-Json
$nameValueBody1 = '{"Name":"Workflow1","value":"' + $workflowResponse1.queries.sig + '"}'
echo $nameValueBody1
$workflowDetails2 = az rest --method post --uri https://management.azure.com/subscriptions/$(SUBSCRIPTION_ID)/resourceGroups/$(RG_LOGIC_APP)/providers/Microsoft.Web/sites/$(LOGIC_APP_NAME)/hostruntime/runtime/webhooks/workflow/api/management/workflows/$(WORKFLOW_NAME2)/triggers/manual/listCallbackUrl?api-version=2018-11-01
$workflowResponse2 = $workflowDetails2 | ConvertFrom-Json
$nameValueBody2 = '{"Name":"Workflow2","value":"' + $workflowResponse2.queries.sig + '"}'
echo $nameValueBody2
Below is what I see in the logs
/usr/bin/az account set --subscription 4xxxxxxxxxxxxxxxxxxxxxxxx0313
/usr/bin/pwsh -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command . '/myagent/_work/_temp/azureclitaskscript1674363859719.ps1'
{"Name":"Workflow1","value":"oxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxA"}
ERROR: Bad Request({"Code":"BadRequest","Message":"Encountered an error (ServiceUnavailable) from host runtime.","Target":null,"Details":[{"Message":"Encountered an error (ServiceUnavailable) from host runtime."},{"Code":"BadRequest"},{"ErrorEntity":{"Code":"BadRequest","Message":"Encountered an error (ServiceUnavailable) from host runtime."}}],"Innererror":null})
{"Name":"Workflow2","value":""}
##[error]Script failed with exit code: 1
/usr/bin/az account clear
If you see the logs, the first API call works fine and I get the SAS Token of the Logic App Workflow. However, the second call is failing with an error as seen in the logs below. The thing that stumps me is how come the first call works and the second fails. So I assume it's not because of any configuration as if that's the case, I believe all calls should fail.
Any pointers please? Thank you!
Not sure of the exact reason why it worked. But introducing a delay of 10 seconds between the 2 API calls did the trick! Refer below.
- task: AzureCLI#2
displayName: get Logic App SAS Token
name: getLASASToken1
inputs:
azureSubscription: ${{ parameters.serviceAccount }}
scriptType: pscore
scriptLocation: inlineScript
inlineScript: |
$workflowDetails1 = az rest --method post --uri https://management.azure.com/subscriptions/$(SUBSCRIPTION_ID)/resourceGroups/$(RG_LOGIC_APP)/providers/Microsoft.Web/sites/$(LOGIC_APP_NAME)/hostruntime/runtime/webhooks/workflow/api/management/workflows/$(WORKFLOW_NAME)/triggers/manual/listCallbackUrl?api-version=2018-11-01 --debug
$workflowResponse1 = $workflowDetails1 | ConvertFrom-Json
$nameValueBody1 = '{"Name":"Workflow1-SASToken","value":"' + $workflowResponse1.queries.sig + '"}'
echo $nameValueBody1
- task: PowerShell#2
inputs:
displayName: 'Delay'
targetType: 'inline'
script: |
Start-Sleep -Seconds 10
pwsh: true
- task: AzureCLI#2
displayName: get Logic App SAS Token 2
name: getLASASToken2
inputs:
azureSubscription: ${{ parameters.serviceAccount }}
scriptType: pscore
scriptLocation: inlineScript
inlineScript: |
$workflowDetails2 = az rest --method post --uri https://management.azure.com/subscriptions/$(SUBSCRIPTION_ID)/resourceGroups/$(RG_LOGIC_APP)/providers/Microsoft.Web/sites/$(LOGIC_APP_NAME)/hostruntime/runtime/webhooks/workflow/api/management/workflows/$(WORKFLOW_NAME)/triggers/manual/listCallbackUrl?api-version=2018-11-01 --debug
$workflowResponse2 = $workflowDetails2 | ConvertFrom-Json
$nameValueBody2 = '{"Name":"Workflow2-SASToken","value":"' + $workflowResponse2.queries.sig + '"}'
echo $nameValueBody2
I'm attempting to learn some more about Azure Functions 2.0 and Docker containers to publish to my Azure instance. I followed to tutorial below with the only difference being that I published with docker to a container registry in azure using visual studio 2019.
https://learn.microsoft.com/en-us/azure/azure-functions/functions-create-your-first-function-visual-studio
This all worked correctly and I was able to start my container and visit the site. However, in the example you can visit /api/function1 and get a response. This works on my localhost but on the live site it returns a 404. It seems that /api/function1 is not reachable after being published.
The app itself returns this when visiting the IP itself so I know it is working. Do I need to do something else in Azure to expose my APIs?
My container log only shows this.
Hosting environment: Production
Content root path: C:\
Now listening on: http://[::]:80
Application started. Press Ctrl+C to shut down.
I grabbed my dockerfile from here
https://github.com/Azure/azure-functions-docker/blob/master/host/2.0/nanoserver-1809/Dockerfile
# escape=`
# Installer image
FROM mcr.microsoft.com/windows/servercore:1809 AS installer-env
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
# Retrieve .NET Core SDK
ENV DOTNET_SDK_VERSION 2.2.402
RUN Invoke-WebRequest -OutFile dotnet.zip https://dotnetcli.blob.core.windows.net/dotnet/Sdk/$Env:DOTNET_SDK_VERSION/dotnet-sdk-$Env:DOTNET_SDK_VERSION-win-x64.zip; `
$dotnet_sha512 = '0fa3bf476b560c8fc70749df37a41580f5b97334b7a1f19d66e32096d055043f4d7ad2828f994306e0a24c62a3030358bcc4579d2d8d439d90f36fecfb2666f6'; `
if ((Get-FileHash dotnet.zip -Algorithm sha512).Hash -ne $dotnet_sha512) { `
Write-Host 'CHECKSUM VERIFICATION FAILED!'; `
exit 1; `
}; `
`
Expand-Archive dotnet.zip -DestinationPath dotnet; `
Remove-Item -Force dotnet.zip
ENV ASPNETCORE_URLS=http://+:80 `
DOTNET_RUNNING_IN_CONTAINER=true `
DOTNET_USE_POLLING_FILE_WATCHER=true `
NUGET_XMLDOC_MODE=skip `
PublishWithAspNetCoreTargetManifest=false `
HOST_COMMIT=69f124faed40d20d9d8e5b8d51f305d249b21512 `
BUILD_NUMBER=12858
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
Invoke-WebRequest -OutFile host.zip https://github.com/Azure/azure-functions-host/archive/$Env:HOST_COMMIT.zip; `
Expand-Archive host.zip .; `
cd azure-functions-host-$Env:HOST_COMMIT; `
/dotnet/dotnet publish /p:BuildNumber=$Env:BUILD_NUMBER /p:CommitHash=$Env:HOST_COMMIT src\WebJobs.Script.WebHost\WebJobs.Script.WebHost.csproj --output C:\runtime
# Runtime image
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2.7-nanoserver-1809
COPY --from=installer-env ["C:\\runtime", "C:\\runtime"]
ENV AzureWebJobsScriptRoot=C:\approot `
WEBSITE_HOSTNAME=localhost:80
CMD ["dotnet", "C:\\runtime\\Microsoft.Azure.WebJobs.Script.WebHost.dll"]
Here's my function1 code for my azure function
public static class Function1
{
[FunctionName("Function1")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
string productid = req.Query["productid"];
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(requestBody);
productid = productid ?? data?.product;
Product newProduct = new Product()
{
ProductNumber = 0,
ProductName = "Unknown",
ProductCost = 0
};
if (Convert.ToInt32(productid) ==1)
{
newProduct = new Product()
{
ProductCost = 100,
ProductName = "Lime Tree",
ProductNumber = 1
};
}
else if(Convert.ToInt32(productid) == 2)
{
newProduct = new Product()
{
ProductCost = 500,
ProductName = "Lemon Tree",
ProductNumber = 2
};
}
return productid != null
? (ActionResult)new JsonResult(newProduct)
: new BadRequestObjectResult("Please pass a name on the query string or in the request body");
}
Here's a photo of my container running with my image.
I'm new to this so any advice would be helpful for sure!
Thanks!
First, I don't know if you really need to (or want to) run Functions on Windows containers. If you want to run in a container, I would probably opt for Linux. For that, this is an example Dockerfile. It does build on top of the Microsoft-provided base image. So you don't have to build that from scratch.
I'm sure there is also a base image for Windows that is already build. If you need it, just look around in the similiar repo I guess.
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
WORKDIR /app
COPY . ./
RUN dotnet publish myfunction -c Release -o myfunction /out
FROM mcr.microsoft.com/azure-functions/dotnet:3.0 AS base
WORKDIR /app
EXPOSE 80
COPY --from=build-env /app/ao-backendfunctions/out .
ENV AzureWebJobsScriptRoot=/app
ENV AzureFunctionsJobHost__Logging__Console__IsEnabled=true
The important part is RUN dotnet publish myfunction -c Release -o myfunction /out. Replace myfunction with the (folder) name of your actual Function.
#silent's answer was correct - Linux containers are the way to go for Azure Functions. My environment wasn't set up correctly for Linux containers but once I got a correct environment this worked out of the box.
Here's my latest DockerFile for another project that uses Linux Containers
See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/azure-functions/dotnet:2.0 AS base
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build
WORKDIR /src
COPY ["FunctionTestAppLinux/FunctionTestAppLinux.csproj", "FunctionTestAppLinux/"]
RUN dotnet restore "FunctionTestAppLinux/FunctionTestAppLinux.csproj"
COPY . .
WORKDIR "/src/FunctionTestAppLinux"
RUN dotnet build "FunctionTestAppLinux.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "FunctionTestAppLinux.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENV AzureWebJobsScriptRoot=/app
I am trying to build an base image on azure pipelines, but the connection is refused when pulling an installer form microsoft.
The Dockerfile, from install dotnet samples:
# escape=`
FROM mcr.microsoft.com/windows/servercore:1607
RUN powershell -Command `
$ErrorActionPreference = 'Stop'; `
$ProgressPreference = 'SilentlyContinue'; `
Invoke-WebRequest `
-UseBasicParsing `
-Uri https://dot.net/v1/dotnet-install.ps1 `
-OutFile dotnet-install.ps1; `
./dotnet-install.ps1 `
-InstallDir '/Program Files/dotnet' `
-Channel 3.0 `
-Runtime dotnet; `
Remove-Item -Force dotnet-install.ps1 `
&& setx /M PATH "%PATH%;C:\Program Files\dotnet"
The log:
##[section]Starting: Build an image
==============================================================================
Task : Docker
Description : Build or push Docker images, login or logout, or run a Docker command
Version : 2.160.1
Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/build/docker
==============================================================================
a2745d43-956f-4450-9ff4-25ef833410b3 exists true
[command]"C:\Program Files\Docker\docker.exe" build -f d:\a\8\s\Docker\Docker\wservercore-dotnetcore3.0.Dockerfile --label com.azure.dev.image.system.teamfoundationcollectionuri=https://dev.azure.com/SspCtt/ --label com.azure.dev.image.system.teamproject=GOD --label com.azure.dev.image.build.repository.name=GOD --label com.azure.dev.image.build.sourceversion=4 --label com.azure.dev.image.build.repository.uri=https://dev.azure.com/SspCtt/ --label com.azure.dev.image.build.sourcebranchname=GOD --label "com.azure.dev.image.build.definitionname=Build servicecore-dotnetcore3.0 image" --label com.azure.dev.image.build.buildnumber=20191204.4 --label com.azure.dev.image.build.builduri=vstfs:///Build/Build/4 -t dockerhub:4 d:\a\8\s\Docker\Docker
Sending build context to Docker daemon 2.56kB
Step 1/11 : FROM mcr.microsoft.com/windows/servercore:1607
1607: Pulling from windows/servercore
3889bb8d808b: Already exists
57e8a97eaa75: Pulling fs layer
57e8a97eaa75: Verifying Checksum
57e8a97eaa75: Download complete
57e8a97eaa75: Pull complete
Digest: sha256:f5d4abf787650d742504be54e97f62874722b0747ad204108610dd25b2d66cd0
Status: Downloaded newer image for mcr.microsoft.com/windows/servercore:1607
---> 5b0fdc7e6814
Step 2/11 : RUN powershell -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest -UseBasicParsing -Uri https://dot.net/v1/dotnet-install.ps1 -OutFile dotnet-install.ps1; ./dotnet-install.ps1 -InstallDir '/Program Files/dotnet' -Channel 3.0 -Runtime dotnet; Remove-Item -Force dotnet-install.ps1 && setx /M PATH "%PATH%;C:\Program Files\dotnet"
---> Running in 56585c5966de
[91mInvoke-WebRequest : The underlying connection was closed: An unexpected error
[0m[91moccurred on a send.
At line:1 char:76
[0m[91m+ ... yContinue'; Invoke-WebRequest -UseBasicParsing -Uri https://dot.net/v ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[0m[91m + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:Htt
pWebRequest) [Invoke-WebRequest], WebException
[0m[91m + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShe
ll.Commands.InvokeWebRequestCommand
[0m[91m
[0mThe command 'cmd /S /C powershell -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest -UseBasicParsing -Uri https://dot.net/v1/dotnet-install.ps1 -OutFile dotnet-install.ps1; ./dotnet-install.ps1 -InstallDir '/Program Files/dotnet' -Channel 3.0 -Runtime dotnet; Remove-Item -Force dotnet-install.ps1 && setx /M PATH "%PATH%;C:\Program Files\dotnet"' returned a non-zero code: 1
##[error]The process 'C:\Program Files\Docker\docker.exe' failed with exit code 1
##[section]Finishing: Build an image
Edit:
I managed to get it to accept 1 parameter. Apparently it hates accepting 2. Now I've got another exception: remote server returning 401 unauthorized. I guess the solution for this is to not use more than 1 parameter, but that's not really a solution. Sounds like a bug to me.
Original question:
I'm at my wit's end on this one.
I have a powershell script that I'd like to execute during a Release that uploads an archived copy of the build to a document library in SharePoint. The build server that hosts TFS 2017 is running Powershell 4. When I RDP in and run the below script in ISE on the same server (precisely where TFS appears to be executing things in the tasks), it works, provided that I add the environment variables where they are commented in the script below.
When I run the same exact script (I'm running it from the drop folder) via TFS, it produces the error:
2017-10-17T13:48:52.5561597Z D:\BuildAgentWorkFolder\f00869677\Git\drop\publish_to_sharepoint.ps1 D:\Integration_20171017.2.zip Integration_20171017.2
2017-10-17T13:48:53.0241597Z Connecting to http://sharepoint_server/sites/TFS_DefaultCollection/NET as srv_promote...
2017-10-17T13:48:53.2737597Z ##[error]D:\BuildAgentWorkFolder\f00869677\Git\drop\publish_to_sharepoin
2017-10-17T13:48:53.2737597Z ##[error]t.ps1 : Cannot bind argument to parameter 'String' because it is null.
which is crazy, because you can clearly see the non-null arguments in the line executing the script.
I have tried specifying the type in the param section, like [string]$filePathToUpload. I have tried specifying the parameters in the command line arguments list, like .\publish_to_sharepoint.ps1 -filePathToUpload "..." -fileName "...", both with and without quotation marks.
One thing to note is when I try to run the task with an in-line powershell script-- because of the character limit, I can only paste up to the first "Write-Host" line-- it passes the parameter step without error and the release passes.
Is this a bug with TFS Powershell task? I can't wrap my head around where this error is coming from.
Thanks in advance. Below are the relevant details.
Powershell script:
param(
$filePathToUpload,
$fileName
)
#$Env:SharePointDomain = "..."
#$Env:SharePointBaseUrl = "http://sharepoint_server"
#$Env:SharePointSite = "/sites/TFS_DefaultCollection/NET/"
#$Env:SharePointUsername = "username"
#$Env:SharePointPassword = "password"
#$Env:SharePointLibrary = "library_name"
Add-Type -AssemblyName "Microsoft.SharePoint.Client, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL"
Add-Type -AssemblyName "Microsoft.SharePoint.Client.Runtime, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL"
Write-Host 'Connecting to'$Env:SharePointBaseUrl$Env:SharePointSite' as '$Env:SharePointUsername'...'
try{
$sharepointFullUrl = $Env:SharePointBaseUrl + $Env:SharePointSite
$clientContext = New-Object Microsoft.SharePoint.Client.ClientContext $sharepointFullUrl
$clientContext.Credentials = New-Object System.Net.NetworkCredential $Env:SharePointUsername, (ConvertTo-SecureString $Env:SharePointPassword -AsPlainText -Force)
$web = $clientContext.Web
$clientContext.Load($web)
$clientContext.ExecuteQuery();
$relDestFilePath = $Env:SharePointSite + $Env:SharePointLibrary + "/" + $fileName
$fStream = New-Object IO.FileStream $filePathToUpload ,'Open','Read','Read'
[Microsoft.SharePoint.Client.File]::SaveBinaryDirect($clientContext, $relDestFilePath, $fStream, $true)
Write-Host 'Successfully uploaded'$fileName' to SharePoint document library '$Env:SharePointLibrary'.'
}
catch {
Write-Error $_
}
Release Task Detail:
Release Environment Variables:
Powershell Task Log
2017-10-17T13:48:52.5405597Z . 'D:\BuildAgentWorkFolder\f00869677\Git\drop\publish_to_sharepoint.ps1' D:\Integration_20171017.2.zip Integration_20171017.2
2017-10-17T13:48:52.5561597Z C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "$env:PSModulePath= $env:PSModulePath + ';' + $([system.io.path]::combine($env:AGENT_HOMEDIRECTORY, 'agent\worker\modules')); try { [System.Security.Cryptography.ProtectedData] | Out-Null } catch { Write-Verbose 'Adding assemly: System.Security' ; Add-Type -AssemblyName 'System.Security' ; [System.Security.Cryptography.ProtectedData] | Out-Null } ; Invoke-Expression -Command ([System.Text.Encoding]::UTF8.GetString([System.Security.Cryptography.ProtectedData]::Unprotect([System.Convert]::FromBase64String('AQAAANCMnd8BFdERjHoAwE/Cl+sAmMDwyguygfTgNLUK3BteusFUlUwAAAAACAAAAAAADZgAAwAAAABAAAACMb/7FzkttmPEf8rMCA10mAAAAAASAAACgAAAAEAAAAN7Pqk+I01BNW4lONiyiuhArrpBqYAAiGrvCfLy/fPm3YiAEuhiuhKwcUEIZFza2IcrqjhKCe4Qn8qRcPMfDEiw82ZUKdNYCrzUjayfThC97Vm3/lNgP15sgTr0NpJwsfvs7fz6zG3zwqwNeu4ivYzcYI/bYd+y608v+jh3d+8vzeQgyIGhto+9WcJlIaCnYv5qymVD7nTME8pnYz+DfNkP02s50jkCySimKgVHGIUAAAAkXCoQxu5+9njKHMCkhB2FSpdivg='), [System.Convert]::FromBase64String('McDlBBSayxJHIwJ35ERNNQ=='), [System.Security.Cryptography.DataProtectionScope]::CurrentUser))) ; if (!(Test-Path -LiteralPath variable:\LastExitCode)) { Write-Verbose 'Last exit code is not set.' } else { Write-Verbose ('$LastExitCode: {0}' -f $LastExitCode) ; exit $LastExitCode }"
2017-10-17T13:48:52.5561597Z Executing the following powershell script. (workingFolder = D:\BuildAgentWorkFolder\f00869677)
2017-10-17T13:48:52.5561597Z D:\BuildAgentWorkFolder\f00869677\Git\drop\publish_to_sharepoint.ps1 D:\Integration_20171017.2.zip Integration_20171017.2
2017-10-17T13:48:53.0241597Z Connecting to http://sharepoint_server/sites/TFS_DefaultCollection/NET as srv_promote...
2017-10-17T13:48:53.2737597Z ##[error]D:\BuildAgentWorkFolder\f00869677\Git\drop\publish_to_sharepoin
2017-10-17T13:48:53.2737597Z ##[error]t.ps1 : Cannot bind argument to parameter 'String' because it is null.
2017-10-17T13:48:53.2737597Z ##[error]At line:1 char:1
2017-10-17T13:48:53.2737597Z ##[error]+ .
2017-10-17T13:48:53.2737597Z ##[error]'D:\BuildAgentWorkFolder\f00869677\Git\drop\publish_to_sharepo
2017-10-17T13:48:53.2737597Z ##[error]...
2017-10-17T13:48:53.2737597Z ##[error]+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2017-10-17T13:48:53.2737597Z ##[error]~~~
2017-10-17T13:48:53.2737597Z ##[error] + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorExcep
2017-10-17T13:48:53.2737597Z ##[error] tion
2017-10-17T13:48:53.2737597Z ##[error] + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorExceptio
2017-10-17T13:48:53.2737597Z ##[error] n,publish_to_sharepoint.ps1
2017-10-17T13:48:53.2737597Z ##[error]
2017-10-17T13:48:53.2737597Z ##[error]Process completed with exit code 0 and had 1 error(s) written to the error stream.
This is the issue: $Env:SharePointPassword. Secrets aren't stored as environment variables. Modify your script and pass in the password as a parameter.
I\m unable to understand how to set gcAllowVeryLargeObjectsruntime param for worker role. I set this pram in app.config. But it doesnt work. As I understand I need to somehow config it in config file of wotker host.
Update: Final solution based on answer
ServiceDefinition.csdef
<WorkerRole name="XXX" vmsize="Standard_D4">
<Startup>
<Task commandLine="myStartup.cmd" executionContext="elevated" taskType="simple" >
<Environment>
<Variable name="yyy" value="yyy" />
</Environment>
</Task>
</Startup>
Next files should be added to worker project as content with Copy Local Always
startup.ps1
#Configure Server GC and Background GC settings
Function ChangeGCSettings
{
param ([string]$filename,[bool]$enableServerGC,[bool]$enableBackgroundGC,[bool]$enableVeryLargeGC)
$xml = New-Object XML
if (Test-Path ($filename))
{
$xml.Load($filename)
}
else
{
#config file doesn't exist create a now one
[System.Xml.XmlDeclaration]$xmlDeclaration = $xml.CreateXmlDeclaration("1.0","utf-8",$null)
$xml.AppendChild($xmlDeclaration)
}
# Check if we already have a configuration section - if not create it
$conf = $xml.configuration
if ($conf -eq $null)
{
$conf = $xml.CreateElement("configuration")
$xml.AppendChild($conf)
}
# Check if we already have a runtime section - if not create it
$runtime = $conf.runtime
if ($runtime -eq $null)
{
#runtime element doesn't exist
$runtime = $xml.CreateElement("runtime")
$conf.AppendChild($runtime)
}
# configure ServerGC
$gcserver = $runtime.gcServer
if ($gcserver -eq $null)
{
$gcserver = $xml.CreateElement("gcServer")
$gcserver.SetAttribute("enabled",$enableServerGC.ToString([System.Globalization.CultureInfo]::InvariantCulture).ToLower())
$runtime.AppendChild($gcserver);
}
else
{
$gcserver.enabled=$enableServerGC.ToString([System.Globalization.CultureInfo]::InvariantCulture).ToLower()
}
# configure gcAllowVeryLargeObjectsruntime
$gcAllowVeryLargeObjects = $runtime.gcAllowVeryLargeObjects
if ($gcAllowVeryLargeObjects -eq $null)
{
$gcAllowVeryLargeObjects = $xml.CreateElement("gcAllowVeryLargeObjects")
$gcAllowVeryLargeObjects.SetAttribute("enabled",$enableVeryLargeGC.ToString([System.Globalization.CultureInfo]::InvariantCulture).ToLower())
$runtime.AppendChild($gcAllowVeryLargeObjects);
}
else
{
$gcAllowVeryLargeObjects.enabled=$enableVeryLargeGC.ToString([System.Globalization.CultureInfo]::InvariantCulture).ToLower()
}
# configure Background GC
# .NET 4.5 is required for Bacground Server GC
# since 4.5 is an in-place upgrade for .NET 4.0 the new Background Server GC mode is available
# even if you target 4.0 in your application as long as the .NET 4.5 runtime is installed (Windows Server 2012 or higher by default)
#
# See http://blogs.msdn.com/b/dotnet/archive/2012/07/20/the-net-framework-4-5-includes-new-garbage-collector-enhancements-for-client-and-server-apps.aspx
$gcConcurrent = $runtime.gcConcurrent
if ($gcConcurrent -eq $null)
{
$gcConcurrent = $xml.CreateElement("gcConcurrent")
$gcConcurrent.SetAttribute("enabled",$enableBackgroundGC.ToString([System.Globalization.CultureInfo]::InvariantCulture).ToLower())
$runtime.AppendChild($gcConcurrent);
}
else
{
$gcConcurrent.enabled=$enableBackgroundGC.ToString([System.Globalization.CultureInfo]::InvariantCulture).ToLower()
}
$xml.Save($filename)
}
# Enable Background Server GC
ChangeGCSettings "${env:RoleRoot}\base\x64\WaWorkerHost.exe.config" $true $true $true
myStartup.cmd
REM Attempt to set the execution policy by using PowerShell version 2.0 syntax.
REM PowerShell version 2.0 isn't available. Set the execution policy by using the PowerShell version 1.0 calling method.
PowerShell -Command "Set-ExecutionPolicy Unrestricted" >> "%TEMP%\StartupLog1.txt" 2>&1
PowerShell .\startup.ps1 >> "%TEMP%\StartupLog2.txt" 2>&1
REM If an error occurred, return the errorlevel.
EXIT /B %errorlevel%
Check out http://blogs.msdn.com/b/cie/archive/2013/11/14/enable-server-gc-mode-for-your-worker-role.aspx which uses a start script to enable Server GC in a worker role. You should be able to easily modify this to change the gcAllowVeryLargeObjectsruntime property.