Skip to content

Commit 94a0163

Browse files
Publish a web app to Azure with Visual Studio
1 parent 5f4a940 commit 94a0163

File tree

549 files changed

+162214
-50
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

549 files changed

+162214
-50
lines changed

AzureModule.sln

Lines changed: 0 additions & 50 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Publish a web app to Azure with Visual Studio
2+
3+
![alt text](image.png)
4+
5+
![alt text](image-1.png)
6+
7+
![alt text](image-2.png)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using azurewebappsdemo.Models;
2+
using Microsoft.AspNetCore.Mvc;
3+
using System.Diagnostics;
4+
5+
namespace azurewebappsdemo.Controllers
6+
{
7+
public class HomeController : Controller
8+
{
9+
private readonly ILogger<HomeController> _logger;
10+
11+
public HomeController(ILogger<HomeController> logger)
12+
{
13+
_logger = logger;
14+
}
15+
16+
public IActionResult Index()
17+
{
18+
return View();
19+
}
20+
21+
public IActionResult Privacy()
22+
{
23+
return View();
24+
}
25+
26+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
27+
public IActionResult Error()
28+
{
29+
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
30+
}
31+
}
32+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace azurewebappsdemo.Models
2+
{
3+
public class ErrorViewModel
4+
{
5+
public string? RequestId { get; set; }
6+
7+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
8+
}
9+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
var builder = WebApplication.CreateBuilder(args);
2+
3+
// Add services to the container.
4+
builder.Services.AddControllersWithViews().AddRazorRuntimeCompilation();
5+
6+
var app = builder.Build();
7+
8+
// Configure the HTTP request pipeline.
9+
if (!app.Environment.IsDevelopment())
10+
{
11+
app.UseExceptionHandler("/Home/Error");
12+
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
13+
app.UseHsts();
14+
}
15+
16+
app.UseHttpsRedirection();
17+
app.UseStaticFiles();
18+
19+
app.UseRouting();
20+
21+
app.UseAuthorization();
22+
23+
app.MapControllerRoute(
24+
name: "default",
25+
pattern: "{controller=Home}/{action=Index}/{id?}");
26+
27+
app.Run();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
4+
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
5+
-->
6+
<Project>
7+
<PropertyGroup>
8+
<WebPublishMethod>MSDeploy</WebPublishMethod>
9+
<ResourceId>/subscriptions/1ebbb56e-2979-41cb-a605-97e7b35bcac9/resourcegroups/learn-cc95d38d-7a6a-4e80-81cd-50672b4df8f2/providers/Microsoft.Web/sites/azurewebappsdemo</ResourceId>
10+
<ResourceGroup>learn-cc95d38d-7a6a-4e80-81cd-50672b4df8f2</ResourceGroup>
11+
<PublishProvider>AzureWebSite</PublishProvider>
12+
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
13+
<LastUsedPlatform>Any CPU</LastUsedPlatform>
14+
<SiteUrlToLaunchAfterPublish>https://azurewebappsdemo.azurewebsites.net</SiteUrlToLaunchAfterPublish>
15+
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
16+
<ExcludeApp_Data>false</ExcludeApp_Data>
17+
<ProjectGuid>440ddaef-5281-4db7-9b6e-4a190ae2d664</ProjectGuid>
18+
<MSDeployServiceURL>azurewebappsdemo.scm.azurewebsites.net:443</MSDeployServiceURL>
19+
<DeployIisAppPath>azurewebappsdemo</DeployIisAppPath>
20+
<RemoteSitePhysicalPath />
21+
<SkipExtraFilesOnServer>true</SkipExtraFilesOnServer>
22+
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
23+
<EnableMSDeployBackup>true</EnableMSDeployBackup>
24+
<EnableMsDeployAppOffline>true</EnableMsDeployAppOffline>
25+
<UserName>$azurewebappsdemo</UserName>
26+
<_SavePWD>true</_SavePWD>
27+
<_DestinationType>AzureWebSite</_DestinationType>
28+
<InstallAspNetCoreSiteExtension>false</InstallAspNetCoreSiteExtension>
29+
</PropertyGroup>
30+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
4+
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
5+
-->
6+
<Project>
7+
<PropertyGroup>
8+
<TimeStampOfAssociatedLegacyPublishXmlFile />
9+
<EncryptedPassword>AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAANWAWhs6xVUOYa3xrtrhpIgAAAAACAAAAAAAQZgAAAAEAACAAAAD8B12o9HnkMP7oXc4nFMf9VewHbNgmDIoXOoXu9OljkAAAAAAOgAAAAAIAACAAAACRX0vOOrMJKgZQ1NfY2zcaVGhhGc7Qid1LqvJ3Hus/dqAAAAD4S+gmmAfCT0LHpOi/2EQ9DYVDZuHqEYlwPI9qox86+TTmdmguwOfD0O4xB09FTQw+yXJlnbwo/5lPWTE4oH7wWfnVl2bjL6Pt75FinxwC6/4eooDbznaKjEV1/CN78Tb7gkm517QrRsaNZWdx1ezVmEhXIqKrcB036Nwlr+nudI3qucu+3UzrIe5YZQd0E7D73dGCNaE76RnWJJkKDuBsQAAAANA4YzSyWSbdlzbcvNiElVv63xjY+U9gwSUbUe0+hxaumqDIYVYCtCt4UxIygv2R9N2s8DjRBBN63Mo5sxkQaiI=</EncryptedPassword>
10+
<History>True|2024-02-17T16:21:20.8267578Z;</History>
11+
<LastFailureDetails />
12+
<IsBasicAuthAllowed>True</IsBasicAuthAllowed>
13+
</PropertyGroup>
14+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
3+
"contentVersion": "1.0.0.0",
4+
"metadata": {
5+
"_dependencyType": "compute.appService.windows"
6+
},
7+
"parameters": {
8+
"resourceGroupName": {
9+
"type": "string",
10+
"defaultValue": "learn-cc95d38d-7a6a-4e80-81cd-50672b4df8f2",
11+
"metadata": {
12+
"description": "Name of the resource group for the resource. It is recommended to put resources under same resource group for better tracking."
13+
}
14+
},
15+
"resourceGroupLocation": {
16+
"type": "string",
17+
"defaultValue": "westus",
18+
"metadata": {
19+
"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."
20+
}
21+
},
22+
"resourceName": {
23+
"type": "string",
24+
"defaultValue": "azurewebappsdemo",
25+
"metadata": {
26+
"description": "Name of the main resource to be created by this template."
27+
}
28+
},
29+
"resourceLocation": {
30+
"type": "string",
31+
"defaultValue": "[parameters('resourceGroupLocation')]",
32+
"metadata": {
33+
"description": "Location of the resource. By default use resource group's location, unless the resource provider is not supported there."
34+
}
35+
}
36+
},
37+
"variables": {
38+
"appServicePlan_name": "[concat('Plan', uniqueString(concat(parameters('resourceName'), subscription().subscriptionId)))]",
39+
"appServicePlan_ResourceId": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', parameters('resourceGroupName'), '/providers/Microsoft.Web/serverFarms/', variables('appServicePlan_name'))]"
40+
},
41+
"resources": [
42+
{
43+
"type": "Microsoft.Resources/resourceGroups",
44+
"name": "[parameters('resourceGroupName')]",
45+
"location": "[parameters('resourceGroupLocation')]",
46+
"apiVersion": "2019-10-01"
47+
},
48+
{
49+
"type": "Microsoft.Resources/deployments",
50+
"name": "[concat(parameters('resourceGroupName'), 'Deployment', uniqueString(concat(parameters('resourceName'), subscription().subscriptionId)))]",
51+
"resourceGroup": "[parameters('resourceGroupName')]",
52+
"apiVersion": "2019-10-01",
53+
"dependsOn": [
54+
"[parameters('resourceGroupName')]"
55+
],
56+
"properties": {
57+
"mode": "Incremental",
58+
"template": {
59+
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
60+
"contentVersion": "1.0.0.0",
61+
"resources": [
62+
{
63+
"location": "[parameters('resourceLocation')]",
64+
"name": "[parameters('resourceName')]",
65+
"type": "Microsoft.Web/sites",
66+
"apiVersion": "2015-08-01",
67+
"tags": {
68+
"[concat('hidden-related:', variables('appServicePlan_ResourceId'))]": "empty"
69+
},
70+
"dependsOn": [
71+
"[variables('appServicePlan_ResourceId')]"
72+
],
73+
"kind": "app",
74+
"properties": {
75+
"name": "[parameters('resourceName')]",
76+
"kind": "app",
77+
"httpsOnly": true,
78+
"reserved": false,
79+
"serverFarmId": "[variables('appServicePlan_ResourceId')]",
80+
"siteConfig": {
81+
"metadata": [
82+
{
83+
"name": "CURRENT_STACK",
84+
"value": "dotnetcore"
85+
}
86+
]
87+
}
88+
},
89+
"identity": {
90+
"type": "SystemAssigned"
91+
}
92+
},
93+
{
94+
"location": "[parameters('resourceLocation')]",
95+
"name": "[variables('appServicePlan_name')]",
96+
"type": "Microsoft.Web/serverFarms",
97+
"apiVersion": "2015-08-01",
98+
"sku": {
99+
"name": "S1",
100+
"tier": "Standard",
101+
"family": "S",
102+
"size": "S1"
103+
},
104+
"properties": {
105+
"name": "[variables('appServicePlan_name')]"
106+
}
107+
}
108+
]
109+
}
110+
}
111+
}
112+
]
113+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"iisSettings": {
3+
"windowsAuthentication": false,
4+
"anonymousAuthentication": true,
5+
"iisExpress": {
6+
"applicationUrl": "http://localhost:48759",
7+
"sslPort": 44319
8+
}
9+
},
10+
"profiles": {
11+
"azurewebappsdemo": {
12+
"commandName": "Project",
13+
"dotnetRunMessages": true,
14+
"launchBrowser": true,
15+
"applicationUrl": "https://localhost:7151;http://localhost:5228",
16+
"environmentVariables": {
17+
"ASPNETCORE_ENVIRONMENT": "Development"
18+
}
19+
},
20+
"IIS Express": {
21+
"commandName": "IISExpress",
22+
"launchBrowser": true,
23+
"environmentVariables": {
24+
"ASPNETCORE_ENVIRONMENT": "Development"
25+
}
26+
}
27+
}
28+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@{
2+
ViewData["Title"] = "Home Page";
3+
}
4+
5+
<div class="text-center">
6+
<h1 class="display-4">Welcome</h1>
7+
<p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
8+
</div>

0 commit comments

Comments
 (0)