Thursday, 27 June 2024
C# Create Dynamic JSON With Dynamic Keys
In this article, we will create a dynamic JSON.
Step 2: Add dynamic data, in my example, I have an array of nodes and values. So, I am adding values to each.
Azure - The attempt to publish website and failed with HTTP status code 'Unauthorized'
OR
The attempt to publish the ZIP file through failed with HTTP status code Unauthorized.
When you get this error while publishing the Website, App Services, or Azure Function in Azure Portal. You need to update the settings in Azure Portal.
By default, the publish website is restricted for App Services and Azure Function from Visual Studio, we need to enable the settings.
SCM Basic Auth Publishing Credentials
Go to Azure Portal --> Go to App Services/Azure Functions --> Click Configuration --> Enable SCM Basic Auth Publishing Credentials.
Once you enable the settings, you can publish the website from Visual Studio.
Wednesday, 10 April 2024
How to find the reason of HTTP Error 500.30 - ASP.NET Core app failed to start in Azure App Service
HTTP Error 500.30 - The ASP.NET Core app failed to start
If your web app is throwing an error HTTP error 500.30 then how to find the root cause in Azure
There are multiple ways to find the error. Let's discuss the first approach.
Approach 1
Step 1: Go to Azure Portal
Step 2: Click on App Service
Step 3: Click on Diagnose and Solve Problems.
There are multiple ways to find the error. Let's discuss the first approach.
Approach 1
Step 1: Go to Azure Portal
Step 2: Click on App Service
Step 3: Click on Diagnose and Solve Problems.
Step 4: Click on Web App Down
Step 5: Here you can click on the View Details link under .Net Core startup failure and you can find the reason for the app down.
Approach 2
Step 1: Go to App Service
Step 2: Click on Environment Variables
Step 3: Click on App Settings
Step 4: Add new Key "ASPNETCORE_DETAILEDERRORS", Set value =1
Restart the app it will show the error on the page instead of 500.30 - ASP.NET Core app failed to start
That's all about this article, I hope you like it.
Monday, 19 February 2024
Hosting a Static Website Using Amazon S3
In today's world, most websites are static, which means they run no server-side code and only consist of HTML, CSS, and JavaScript. There is no server-side code to run, so there is no reason to host them on a traditional server.
Hosting static websites on an S3 bucket costs one to two dollars monthly and scales to millions of users.
Let's learn how to create a S3 Bucket and host the website.
Step 1: Create a Bucket
You can open S3 from the Amazon console by searching for S3 or clicking the link below. Console at https://console.aws.amazon.com/s3/
1. Click on Create Bucket
2. Enter your Bucket name and select AWS Region.
3. Uncheck block all public access
4. Keep the remaining settings as it is like bucket versioning etc.
5. Click on the Create Bucket button.
6. You will receive the below message.
Step 2: Upload files
1. Click your Bucket Name
3. Click on the add files button and upload your files.
4. I am uploading index.html for now. You can upload your files (CSS/Images/Javascript and HTML)
Upload your file and then click on the Close Button.
Step 3: Allow Public Access
1. Go to permissions and Edit
2. Uncheck Block all public access and click Save changes.
Step 4: Enable Static website hosting
1. Click on your bucket go to Properties and scroll down.
2. Go to Static Website Hosting and Click Edit
3. Enable Static Website and Specify the index document. I am adding an index.html as a startup page.
4. Click Save Changes.
Step 5: Get URL
1. Click on your bucket Name and Go To Properties.
2. Under static website, you can get the static website URL.
Step 6: Set Bucket Policy
1. Clock on Bucket Name and Go to the Permissions Tab.
3. Copy the below lines and Save. Note: You need to enter your Bucket ARN in Resource. You can find Bucket ARN in the Properties Tab.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "aarn:aws:s3:::tssbucket2024/*"
}
]
}
4. Update ARN and press the Save Changes Button.
5. Open the link in the browser and you can see the Website is running.
http://tssbucket2024.s3-website.eu-north-1.amazonaws.com/
This is all about this article. I hope you like it.
Wednesday, 27 December 2023
AWS - Create Copy of DynamoDB Table and learn Backup and Restore Functionality
AWS DynamoDB Back and Restore
There is no direct way to copy DynamoDB tables as of now. So, we must take a backup and restore the table with a new name. Let's learn.
Step 1: Search DynamoDB from the search bar and Click Tabes on the left side. Select the table from the right that you want to take the backup.
Step 2: Click on the Backup Tab, click the Create Back dropdown below, and select Create an on-demand backup.
Step 3: Create on-demand backup, click the Create Backup button.
It will take approx 5 minutes to take the backup and it will change the status to complete.
Step 6: After completion, you can Go to Dynamo DB from the search bar and you can find the backup there then you can press the restore button.
Step 7: Here you can update the table name that you want and press the restore button.
You can see the request submitted successfully.
Step 8: To check the status, you again can go to AWS backup --> Jobs --> and click Restore Jobs.
Step 9: After completion, you can see a new table Under DynamoDb tables
This way you can create a table copy in the DynamoDB.
That's all about this article, thank you.
Sunday, 10 December 2023
Create resource on Azure with Terraform
What is Terraform?
Terraform is an Infrastructure as Code (IaC) software tool offered by HashiCorp. You can provision and manage your infrastructure both on-premises and in the cloud with it.
How to execute Terraform Scripts?
Prerequisite
1. You need an Azure Portal account
2. Install Azure CLI on your local system. Download the installer from the below link
Azure CLI Installer
3. Azure Login on command prompt run (az login) command
4. Install Terraform. Download the installer from the below link. Download AMD64 for 64-bit system. Terraform Download
Let's create a small script to create a resource Group in the Azure portal.
Step 1: Create a Terraform file to create a resource group. Paste the below script into the new file and the name should be anyname.tf
provider "azurerm" { version = "~>2.0" features {}}
resource "azurerm_resource_group" "terraform1" { name = "terraform1" location = "eastus"}
provider "azurerm" {
version = "~>2.0"
features {}
}
resource "azurerm_resource_group" "terraform1" {
name = "terraform1"
location = "eastus"
}
Place the file in any drive. I have placed the file in the D drive. Below is my file. My Resource group name is terraform1. You can write any name.
Step 2: Intialize Terraform.
My file is on D drive. So I have executed the command from D drive.
terraform init
Step 3: Terraform Plan
Execute command terraform plan
Step 4: Terraform Apply
Execute command terraform apply
It will prompt you to perform this action? Write Yes and Enter.
You can see the success message above. Go to the Azure portal, and you can see a new resource group with the name terraform1.
That's all about this article.
Thursday, 20 July 2023
Deploy your website to an Azure VM or Local Machine IIS.
The first step is to ensure IIS is installed on the VM. Open the browser and type localhost to ensure IIS is running. Or type inetmgr in Run. If it is not working this means IIS is not installed.
Install IIS
1. Open the control panel
2. Go To Programs And Features
3. Click on Turn Windows Features on or off
4. Click on Internet Information Services (IIS)
5. Press Ok
It will install IIS on your system. Now when you type localhost in browser and you can see the below screen.
7. You can publish your code to Default Web Site or create a new Website.
8. Let's publish your code on the default website. Right-click on the default website and click Explore. Publish your code and paste it here.
9. Open the browser and type localhost. You can see your website is running. If you are getting below error
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
This means you need to install the .Net Runtime on your VM. My API is in .Net 7. So, I am downloading .net 7 from the link below or from Google based on the specific version. You can download .Net Core based on your .Net core version.
.Net runtime
10. Hurrah, now you can see your website is running.
This is all about this article. Thank you.
Subscribe to:
Posts (Atom)
Enum with Flag Attribute in .NET
In .NET, you can use the Flags attribute with an enum. You can combine multiple values into one to represent a set of bit fields. It is use...
-
OR The attempt to publish the ZIP file through failed with HTTP status code Unauthorized. When you get this error while publishing the Websi...
-
This error normally occurred when you created a report on one SQL version and deploying/opening on another SQL version. I've created ...
-
There are multiple ways to read the PDF, In this article, we will discuss Azure AI Form Recognizer. Let's learn how to read PDF in .NET/...