Skip to content

Commit

Permalink
Create Excel in Azure V4 Function
Browse files Browse the repository at this point in the history
  • Loading branch information
KonduruKeerthi committed Aug 10, 2023
1 parent aede7e6 commit bbb21ad
Show file tree
Hide file tree
Showing 14 changed files with 750 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.6.33723.286
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Console_App", "Console_App\Console_App.csproj", "{8C8BFC35-5F3F-423B-BB0A-F6EB7A835A2D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8C8BFC35-5F3F-423B-BB0A-F6EB7A835A2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8C8BFC35-5F3F-423B-BB0A-F6EB7A835A2D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8C8BFC35-5F3F-423B-BB0A-F6EB7A835A2D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8C8BFC35-5F3F-423B-BB0A-F6EB7A835A2D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C343584F-356A-4748-88A6-D74C362A703F}
EndGlobalSection
EndGlobal
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{8C8BFC35-5F3F-423B-BB0A-F6EB7A835A2D}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Console_App</RootNamespace>
<AssemblyName>Console_App</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace Console_App
{
internal class Program
{
static void Main(string[] args)
{
FileStream imageStream = new FileStream("../../AdventureCycles-Logo.png", FileMode.Open, FileAccess.Read);
imageStream.Position = 0;

//Saves the Excel document in memory stream.
MemoryStream inputStream = new MemoryStream();
imageStream.CopyTo(inputStream);
inputStream.Position = 0;

try
{
Console.WriteLine("Please enter your Azure Functions URL :");
string functionURL = Console.ReadLine();

//Create HttpWebRequest with hosted azure functions URL.
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(functionURL);

//Set request method as POST
req.Method = "POST";

//Get the request stream to save the Excel document stream
Stream stream = req.GetRequestStream();

//Write the Excel document stream into request stream
stream.Write(inputStream.ToArray(), 0, inputStream.ToArray().Length);

//Gets the responce from the Azure Functions.
HttpWebResponse res = (HttpWebResponse)req.GetResponse();

//Saves the Excel stream.
FileStream excelStream = File.Create("Sample.xlsx");
res.GetResponseStream().CopyTo(excelStream);

//Dispose the streams
inputStream.Dispose();
excelStream.Dispose();
}
catch (Exception ex)
{
throw;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Console_App")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Console_App")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("8c8bfc35-5f3f-423b-bb0a-f6eb7a835a2d")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.6.33723.286
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Create_Excel", "Create_Excel\Create_Excel.csproj", "{D486C3DF-D368-450E-8DC0-3801CE22C27D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D486C3DF-D368-450E-8DC0-3801CE22C27D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D486C3DF-D368-450E-8DC0-3801CE22C27D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D486C3DF-D368-450E-8DC0-3801CE22C27D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D486C3DF-D368-450E-8DC0-3801CE22C27D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F3AF13C1-9DD3-4B1A-AC9C-C067E51108B4}
EndGlobalSection
EndGlobal
Loading

0 comments on commit bbb21ad

Please sign in to comment.