Skip to content

Commit

Permalink
Cloudservice (#2)
Browse files Browse the repository at this point in the history
* Working on converting app to a cloud service

* Fixed workflow

* Added msbuild

* Restored packages

* Renamed step

* Installing cspack

* Noted where cspack originally came from

* Quoted everything

* Created an octopus package and uploaded the artifact

* Trying to fix file upload

* Fixed path

* Added new fields required for ARM

* Added new config files

* Fixed up cscfg file

* Fixed the XML

* Build both ASM and ARM cloud service package

* Fixed step names

* Fixed ids

* Fixed instance names

* Include the csdef file in the archive
  • Loading branch information
mcasperson authored May 5, 2021
1 parent 23bd491 commit 0e38811
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 0 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/cloudservice.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: RandomQuotes Cloud Service
on:
push:
jobs:
build:
runs-on: windows-2019
steps:
- name: Add msbuild to PATH
uses: microsoft/[email protected]
- uses: actions/checkout@v1
- name: Nuget Restore
shell: powershell
run: nuget restore RandomQuotes.sln
- name: MSBuild
shell: powershell
run: msbuild.exe RandomQuotes.sln /p:Configuration=Release "/p:Platform=Any CPU" /p:DeployOnBuild=true /p:DeployTarget=Package /p:AutoParameterizationWebConfigConnectionStrings=false
# These files were found under C:\Program Files\Microsoft SDKs\Azure\.NET SDK\v2.9\bin on a local install
- name: Download cspack
shell: powershell
run: Invoke-WebRequest -Uri https://octopus-guides.s3.amazonaws.com/cspack/cspack.zip -OutFile cspack.zip
- name: Extract cspack
shell: powershell
run: mkdir cspack; Expand-Archive -LiteralPath cspack.zip -DestinationPath cspack

- name: CSPack ARM
shell: powershell
run: .\cspack\cspack.exe ServiceDefinitionARM.csdef "/role:WebRole1;RandomQuotes\obj\Production\Package\PackageTmp" "/rolePropertiesFile:WebRole1;.\AzureRoleProperties.txt" "/sitePhysicalDirectories:WebRole1;Web;RandomQuotes\obj\Production\Package\PackageTmp" "/out:RandomQuotes-Azure-Release-ARM.cspkg"
- name: Create Octopus ARM Package
shell: powershell
run: Get-ChildItem -Path RandomQuotes-Azure-Release-ARM.cspkg, ServiceConfiguration.Cloud.ARM.cscfg, ServiceDefinitionARM.csdef | Compress-Archive -DestinationPath RandomQuotes-Azure-Release-ARM.1.0.${{ github.run_number }}.zip

- name: CSPack ASM
shell: powershell
run: .\cspack\cspack.exe ServiceDefinition.csdef "/role:WebRole1;RandomQuotes\obj\Production\Package\PackageTmp" "/rolePropertiesFile:WebRole1;.\AzureRoleProperties.txt" "/sitePhysicalDirectories:WebRole1;Web;RandomQuotes\obj\Production\Package\PackageTmp" "/out:RandomQuotes-Azure-Release-ASM.cspkg"
- name: Create Octopus ASM Package
shell: powershell
run: Get-ChildItem -Path RandomQuotes-Azure-Release-ASM.cspkg, ServiceConfiguration.Cloud.cscfg, ServiceDefinition.csdef | Compress-Archive -DestinationPath RandomQuotes-Azure-Release-ASM.1.0.${{ github.run_number }}.zip

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: 0.0.${{ github.run_number }}
release_name: Release 0.0.${{ github.run_number }}
draft: false
prerelease: false

- name: Upload ARM Zip Release Asset
id: upload-arm-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: .\RandomQuotes-Azure-Release-ARM.1.0.${{ github.run_number }}.zip
asset_name: RandomQuotes-Azure-Release-ARM.1.0.${{ github.run_number }}.zip
asset_content_type: application/zip

- name: Upload ASM Zip Release Asset
id: upload-asm-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: .\RandomQuotes-Azure-Release-ASM.1.0.${{ github.run_number }}.zip
asset_name: RandomQuotes-Azure-Release-ASM.1.0.${{ github.run_number }}.zip
asset_content_type: application/zip
1 change: 1 addition & 0 deletions AzureRoleProperties.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TargetFrameWorkVersion=v4.0
Binary file added RandomQuotes-Azure-Release.cspkg
Binary file not shown.
22 changes: 22 additions & 0 deletions ServiceConfiguration.Cloud.ARM.cscfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<ServiceConfiguration serviceName="AzureCloudServiceCSharp" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="6" osVersion="*" schemaVersion="2015-04.2.6">
<!-- https://docs.microsoft.com/en-us/azure/cloud-services-extended-support/schema-cscfg-file -->
<Role name="WebRole1">
<Instances count="1" />
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />
</ConfigurationSettings>
</Role>

<NetworkConfiguration>
<VirtualNetworkSite name="randomquotes"/>
<AddressAssignments>
<InstanceAddress roleName="WebRole1">
<Subnets>
<Subnet name="default"/>
</Subnets>
</InstanceAddress>
</AddressAssignments>
</NetworkConfiguration>

</ServiceConfiguration>
9 changes: 9 additions & 0 deletions ServiceConfiguration.Cloud.cscfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<ServiceConfiguration serviceName="AzureCloudServiceCSharp" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="6" osVersion="*" schemaVersion="2015-04.2.6">
<Role name="WebRole1">
<Instances count="1" />
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />
</ConfigurationSettings>
</Role>
</ServiceConfiguration>
9 changes: 9 additions & 0 deletions ServiceConfiguration.Local.cscfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<ServiceConfiguration serviceName="AzureCloudServiceCSharp" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="6" osVersion="*" schemaVersion="2015-04.2.6">
<Role name="WebRole1">
<Instances count="1" />
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />
</ConfigurationSettings>
</Role>
</ServiceConfiguration>
18 changes: 18 additions & 0 deletions ServiceDefinition.csdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="AzureCloudServiceCSharp" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2015-04.2.6">
<WebRole name="WebRole1" vmsize="Standard_A1">
<Sites>
<Site name="Web">
<Bindings>
<Binding name="Endpoint1" endpointName="Endpoint1" />
</Bindings>
</Site>
</Sites>
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" />
</ConfigurationSettings>
<Endpoints>
<InputEndpoint name="Endpoint1" protocol="http" port="80" />
</Endpoints>
</WebRole>
</ServiceDefinition>
18 changes: 18 additions & 0 deletions ServiceDefinitionARM.csdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="AzureCloudServiceCSharp" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2015-04.2.6">
<WebRole name="WebRole1" vmsize="Standard_A1">
<Sites>
<Site name="Web">
<Bindings>
<Binding name="Endpoint1" endpointName="Endpoint1" />
</Bindings>
</Site>
</Sites>
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" />
</ConfigurationSettings>
<Endpoints>
<InputEndpoint name="Endpoint1" protocol="http" port="80" />
</Endpoints>
</WebRole>
</ServiceDefinition>

0 comments on commit 0e38811

Please sign in to comment.