From fac4fefece94c5fdf7f1370996fab997b448540b Mon Sep 17 00:00:00 2001 From: Crynners Date: Fri, 10 Dec 2021 09:39:49 +0100 Subject: [PATCH] application conversion to .net 6 --- CryptoBotCore.sln | 24 +-- CryptoBotCore/API/BitfinexAPI.cs | 4 +- CryptoBotCore/AppSettings.json | 2 - CryptoBotCore/CryptoBotCore.csproj | 46 ++--- CryptoBotCore/Program.cs | 15 -- CryptoBotCore/Utility.cs | 8 +- CryptoBotFunction/CryptoBotFunction.csproj | 32 ++-- .../CrBts - Zip Deploy/profile.arm.json | 175 ------------------ .../Properties/serviceDependencies.json | 4 + .../Properties/serviceDependencies.local.json | 5 +- CryptoBotFunction/install_script.ps1 | 7 +- 11 files changed, 66 insertions(+), 256 deletions(-) delete mode 100644 CryptoBotCore/AppSettings.json delete mode 100644 CryptoBotCore/Program.cs delete mode 100644 CryptoBotFunction/Properties/ServiceDependencies/CrBts - Zip Deploy/profile.arm.json diff --git a/CryptoBotCore.sln b/CryptoBotCore.sln index 30cd9a1..34ee418 100644 --- a/CryptoBotCore.sln +++ b/CryptoBotCore.sln @@ -1,11 +1,11 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30717.126 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.31911.260 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CryptoBotCore", "CryptoBotCore\CryptoBotCore.csproj", "{DA2615CF-76EF-4EF8-8AED-730533BD795E}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CryptoBotCore", "CryptoBotCore\CryptoBotCore.csproj", "{6F35ECF7-EF01-4473-A344-2FBD0C3D36D5}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CryptoBotFunction", "CryptoBotFunction\CryptoBotFunction.csproj", "{8631C9AA-A4E5-4257-8BA2-8396CC698D7E}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CryptoBotFunction", "CryptoBotFunction\CryptoBotFunction.csproj", "{E6C11A63-713F-4653-9514-8A65ACDAF036}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -13,14 +13,14 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {DA2615CF-76EF-4EF8-8AED-730533BD795E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DA2615CF-76EF-4EF8-8AED-730533BD795E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DA2615CF-76EF-4EF8-8AED-730533BD795E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DA2615CF-76EF-4EF8-8AED-730533BD795E}.Release|Any CPU.Build.0 = Release|Any CPU - {8631C9AA-A4E5-4257-8BA2-8396CC698D7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8631C9AA-A4E5-4257-8BA2-8396CC698D7E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8631C9AA-A4E5-4257-8BA2-8396CC698D7E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8631C9AA-A4E5-4257-8BA2-8396CC698D7E}.Release|Any CPU.Build.0 = Release|Any CPU + {6F35ECF7-EF01-4473-A344-2FBD0C3D36D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6F35ECF7-EF01-4473-A344-2FBD0C3D36D5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6F35ECF7-EF01-4473-A344-2FBD0C3D36D5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6F35ECF7-EF01-4473-A344-2FBD0C3D36D5}.Release|Any CPU.Build.0 = Release|Any CPU + {E6C11A63-713F-4653-9514-8A65ACDAF036}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E6C11A63-713F-4653-9514-8A65ACDAF036}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E6C11A63-713F-4653-9514-8A65ACDAF036}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E6C11A63-713F-4653-9514-8A65ACDAF036}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/CryptoBotCore/API/BitfinexAPI.cs b/CryptoBotCore/API/BitfinexAPI.cs index b7f3732..dbff4b8 100644 --- a/CryptoBotCore/API/BitfinexAPI.cs +++ b/CryptoBotCore/API/BitfinexAPI.cs @@ -46,12 +46,12 @@ public BitfinexAPI(string pair, Dictionary crede private async Task getCurrentPrice() { - var callResult = await client.GetTickerAsync(); + var callResult = await client.GetTickerAsync($"{pair_base}{pair_quote}"); // Make sure to check if the call was successful if (!callResult.Success) { // Call failed, check callResult.Error for more info - throw new Exception(callResult.Error.Message); + throw new Exception(callResult?.Error?.Message); } else { diff --git a/CryptoBotCore/AppSettings.json b/CryptoBotCore/AppSettings.json deleted file mode 100644 index 8593c62..0000000 --- a/CryptoBotCore/AppSettings.json +++ /dev/null @@ -1,2 +0,0 @@ -{ -} \ No newline at end of file diff --git a/CryptoBotCore/CryptoBotCore.csproj b/CryptoBotCore/CryptoBotCore.csproj index 04ab7f0..db3f8a9 100644 --- a/CryptoBotCore/CryptoBotCore.csproj +++ b/CryptoBotCore/CryptoBotCore.csproj @@ -1,33 +1,35 @@ - + - Exe - netcoreapp3.1 + net6.0 + enable + enable - - - - - - - - - - - - - - - - + + False + 3.20.1 + Content + Microsoft.Azure.Cosmos + false + - - PreserveNewest - + + + + + + + + + + + + + diff --git a/CryptoBotCore/Program.cs b/CryptoBotCore/Program.cs deleted file mode 100644 index a9bd4c5..0000000 --- a/CryptoBotCore/Program.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using System; - -namespace CryptoBotCore -{ - class Program - { - public static void Main(string[] args) - { - } - - } -} diff --git a/CryptoBotCore/Utility.cs b/CryptoBotCore/Utility.cs index 62ec55c..eab6487 100644 --- a/CryptoBotCore/Utility.cs +++ b/CryptoBotCore/Utility.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace CryptoBotCore +namespace CryptoBotCore { public static class Utility { diff --git a/CryptoBotFunction/CryptoBotFunction.csproj b/CryptoBotFunction/CryptoBotFunction.csproj index f1c8ba6..1234e27 100644 --- a/CryptoBotFunction/CryptoBotFunction.csproj +++ b/CryptoBotFunction/CryptoBotFunction.csproj @@ -1,49 +1,49 @@  - netcoreapp3.1 - v3 + net6.0 + v4 - + - - Always - - + Always - + Always Always - + Always - + Always - + Always + + PreserveNewest + Always - + Always - - PreserveNewest + + Always - + Always - + Always diff --git a/CryptoBotFunction/Properties/ServiceDependencies/CrBts - Zip Deploy/profile.arm.json b/CryptoBotFunction/Properties/ServiceDependencies/CrBts - Zip Deploy/profile.arm.json deleted file mode 100644 index 9b2c385..0000000 --- a/CryptoBotFunction/Properties/ServiceDependencies/CrBts - Zip Deploy/profile.arm.json +++ /dev/null @@ -1,175 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_dependencyType": "function.windows.appService" - }, - "parameters": { - "resourceGroupName": { - "type": "string", - "defaultValue": "CBot", - "metadata": { - "description": "Name of the resource group for the resource. It is recommended to put resources under same resource group for better tracking." - } - }, - "resourceGroupLocation": { - "type": "string", - "defaultValue": "germanywestcentral", - "metadata": { - "description": "Location of the resource group. Resource groups could have different location than resources, however by default we use API versions from latest hybrid profile which support all locations for resource types we support." - } - }, - "resourceName": { - "type": "string", - "defaultValue": "CrBts", - "metadata": { - "description": "Name of the main resource to be created by this template." - } - }, - "resourceLocation": { - "type": "string", - "defaultValue": "[parameters('resourceGroupLocation')]", - "metadata": { - "description": "Location of the resource. By default use resource group's location, unless the resource provider is not supported there." - } - } - }, - "resources": [ - { - "type": "Microsoft.Resources/resourceGroups", - "name": "[parameters('resourceGroupName')]", - "location": "[parameters('resourceGroupLocation')]", - "apiVersion": "2019-10-01" - }, - { - "type": "Microsoft.Resources/deployments", - "name": "[concat(parameters('resourceGroupName'), 'Deployment', uniqueString(concat(parameters('resourceName'), subscription().subscriptionId)))]", - "resourceGroup": "[parameters('resourceGroupName')]", - "apiVersion": "2019-10-01", - "dependsOn": [ - "[parameters('resourceGroupName')]" - ], - "properties": { - "mode": "Incremental", - "expressionEvaluationOptions": { - "scope": "inner" - }, - "parameters": { - "resourceGroupName": { - "value": "[parameters('resourceGroupName')]" - }, - "resourceGroupLocation": { - "value": "[parameters('resourceGroupLocation')]" - }, - "resourceName": { - "value": "[parameters('resourceName')]" - }, - "resourceLocation": { - "value": "[parameters('resourceLocation')]" - } - }, - "template": { - "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "resourceGroupName": { - "type": "string" - }, - "resourceGroupLocation": { - "type": "string" - }, - "resourceName": { - "type": "string" - }, - "resourceLocation": { - "type": "string" - } - }, - "variables": { - "storage_name": "[toLower(concat('storage', uniqueString(concat(parameters('resourceName'), subscription().subscriptionId))))]", - "appServicePlan_name": "[concat('Plan', uniqueString(concat(parameters('resourceName'), subscription().subscriptionId)))]", - "storage_ResourceId": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', parameters('resourceGroupName'), '/providers/Microsoft.Storage/storageAccounts/', variables('storage_name'))]", - "appServicePlan_ResourceId": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', parameters('resourceGroupName'), '/providers/Microsoft.Web/serverFarms/', variables('appServicePlan_name'))]", - "function_ResourceId": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', parameters('resourceGroupName'), '/providers/Microsoft.Web/sites/', parameters('resourceName'))]" - }, - "resources": [ - { - "location": "[parameters('resourceLocation')]", - "name": "[parameters('resourceName')]", - "type": "Microsoft.Web/sites", - "apiVersion": "2015-08-01", - "tags": { - "[concat('hidden-related:', variables('appServicePlan_ResourceId'))]": "empty" - }, - "dependsOn": [ - "[variables('appServicePlan_ResourceId')]", - "[variables('storage_ResourceId')]" - ], - "kind": "functionapp", - "properties": { - "name": "[parameters('resourceName')]", - "kind": "functionapp", - "httpsOnly": true, - "reserved": false, - "serverFarmId": "[variables('appServicePlan_ResourceId')]", - "siteConfig": { - "alwaysOn": true - } - }, - "identity": { - "type": "SystemAssigned" - }, - "resources": [ - { - "name": "appsettings", - "type": "config", - "apiVersion": "2015-08-01", - "dependsOn": [ - "[variables('function_ResourceId')]" - ], - "properties": { - "AzureWebJobsDashboard": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storage_name'), ';AccountKey=', listKeys(variables('storage_ResourceId'), '2017-10-01').keys[0].value, ';EndpointSuffix=', 'core.windows.net')]", - "AzureWebJobsStorage": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storage_name'), ';AccountKey=', listKeys(variables('storage_ResourceId'), '2017-10-01').keys[0].value, ';EndpointSuffix=', 'core.windows.net')]", - "FUNCTIONS_EXTENSION_VERSION": "~3", - "FUNCTIONS_WORKER_RUNTIME": "dotnet" - } - } - ] - }, - { - "location": "[parameters('resourceGroupLocation')]", - "name": "[variables('storage_name')]", - "type": "Microsoft.Storage/storageAccounts", - "apiVersion": "2017-10-01", - "tags": { - "[concat('hidden-related:', concat('/providers/Microsoft.Web/sites/', parameters('resourceName')))]": "empty" - }, - "properties": { - "supportsHttpsTrafficOnly": true - }, - "sku": { - "name": "Standard_LRS" - }, - "kind": "Storage" - }, - { - "location": "[parameters('resourceGroupLocation')]", - "name": "[variables('appServicePlan_name')]", - "type": "Microsoft.Web/serverFarms", - "apiVersion": "2015-08-01", - "sku": { - "name": "S1", - "tier": "Standard", - "family": "S", - "size": "S1" - }, - "properties": { - "name": "[variables('appServicePlan_name')]" - } - } - ] - } - } - } - ] -} \ No newline at end of file diff --git a/CryptoBotFunction/Properties/serviceDependencies.json b/CryptoBotFunction/Properties/serviceDependencies.json index c264e8c..df4dcc9 100644 --- a/CryptoBotFunction/Properties/serviceDependencies.json +++ b/CryptoBotFunction/Properties/serviceDependencies.json @@ -2,6 +2,10 @@ "dependencies": { "appInsights1": { "type": "appInsights" + }, + "storage1": { + "type": "storage", + "connectionId": "AzureWebJobsStorage" } } } \ No newline at end of file diff --git a/CryptoBotFunction/Properties/serviceDependencies.local.json b/CryptoBotFunction/Properties/serviceDependencies.local.json index 5a956e8..155d87e 100644 --- a/CryptoBotFunction/Properties/serviceDependencies.local.json +++ b/CryptoBotFunction/Properties/serviceDependencies.local.json @@ -1,7 +1,8 @@ { "dependencies": { - "appInsights1": { - "type": "appInsights.sdk" + "storage1": { + "type": "storage.emulator", + "connectionId": "AzureWebJobsStorage" } } } \ No newline at end of file diff --git a/CryptoBotFunction/install_script.ps1 b/CryptoBotFunction/install_script.ps1 index 46d08ec..8f81179 100644 --- a/CryptoBotFunction/install_script.ps1 +++ b/CryptoBotFunction/install_script.ps1 @@ -374,9 +374,9 @@ if ( $existingFunctionAppEntity.Count -gt 0 ) #Tvorba Azure function s úplně novým Azure app plánem if( "false" -eq $CreateAzureLog){ - $FunctionAppResult = az functionapp create -g $resourceGroupName -n $azFunctionName -s $storageAccountName --only-show-errors --disable-app-insights --functions-version 3 --consumption-plan-location $location + $FunctionAppResult = az functionapp create -g $resourceGroupName -n $azFunctionName -s $storageAccountName --only-show-errors --disable-app-insights --runtime "dotnet" --consumption-plan-location $location }else { - $FunctionAppResult = az functionapp create -g $resourceGroupName -n $azFunctionName -s $storageAccountName --app-insights $appInsightsName --only-show-errors --functions-version 3 --consumption-plan-location $location + $FunctionAppResult = az functionapp create -g $resourceGroupName -n $azFunctionName -s $storageAccountName --app-insights $appInsightsName --only-show-errors --runtime "dotnet" --consumption-plan-location $location } } @@ -399,7 +399,8 @@ Write-Host "[Step 7 / 9] Function app -> DONE" -ForegroundColor cyan Write-Host "[Step 8 / 9] Function app settings uploading -> Starting..." -ForegroundColor cyan $appsettingsResult = az functionapp config appsettings set --name $azFunctionName --resource-group $resourceGroupName ` - --settings "Name=$Name" ` + --settings "FUNCTIONS_EXTENSION_VERSION=~4" ` + "Name=$Name" ` "ExchangeName=$ExchangeName" ` "Currency=$Currency" ` "Fiat=$Fiat" `