skip to Main Content

I am working through a tutorial on the Microsoft Learn area for uploading image data in the cloud with Azure storage.

The tutorial instructs users to deploy a web app from a public Github sample repository, configure web app settings, and then save it to a storage account.

I have completed the steps: Hi there,

I am working through a tutorial on the Microsoft Learn area for uploading image data in the cloud with Azure storage.

https://learn.microsoft.com/en-us/azure/event-grid/storage-upload-process-images?tabs=dotnet%2Cazure-powershell#feedback

The tutorial instructs users to deploy a web app from a public Github sample repository, configure web app settings, and then save it to a storage account.

I have completed the steps:

Deploy the sample app from the GitHub repository
Configure web app settings
I am halfway through the ‘Upload an Image’ section, but the image isn’t showing in the Microsoft Azure Storage account I have.

Any ideas of what to check? Is there a way I can check my web app configuration settings, including viewing the linked storage account?
Thanks,

Robert

2

Answers


  1. In my App service:

    enter image description here

    I used powershell instead of the azure cli and noticed the powershell commands are incorrect. Here is a small script that I used to set the Application Settings:

    Connect-AzAccount
    
    $resourceGroupName  = "your_resource_group_name"
    $webAppName         = "your_webapp_name"
    $storageAccountName = "your_storage_account_name"
    
    $blobStorageAccountKey = (Get-AzStorageAccountKey -Name $storageAccountName -ResourceGroupName $resourceGroupName)[0].Value
    
    $appSettings = @{ `
        "AzureStorageConfig__ImageContainer"    = "images";
        "AzureStorageConfig__AccountName"       = $storageAccountName;
        "AzureStorageConfig__ThumbnailContainer"= "thumbnails";
        "AzureStorageConfig__AccountKey"        = $blobStorageAccountKey;
        "testrun"                               = "1";
    }
    
    Set-AzWebApp -Name $webAppName -ResourceGroupName $resourceGroupName -AppSettings $appSettings
    Disconnect-AzAccount
    

    Fill in the variables and it should set them correct (if that is not yet the case).

    Container result after uploading an image:
    And the result in the container

    The webapp will also provide feedback if it cannot retrieve the storage details:
    error wrong storage settings

    Hopefully this helps.

    Kind regards

    Login or Signup to reply.
  2. I have used the PowerShell commands and able to upload and view images without any issues.

    Please check the below commands and follow the same without any change.

    New-AzResourceGroup -Name -Location southeastasia
    
    $blobStorageAccount="myblobha"
    
    New-AzStorageAccount -ResourceGroupName myRGroup -Name $blobStorageAccount -SkuName Standard_LRS -Location southeastasia -Kind StorageV2 -AccessTier Hot
    
    
    $blobStorageAccountKey = ((Get-AzStorageAccountKey -ResourceGroupName myRGroup -Name $blobStorageAccount)| Where-Object {$_.KeyName -eq "key1"}).Value
    $blobStorageContext = New-AzStorageContext -StorageAccountName $blobStorageAccount -StorageAccountKey $blobStorageAccountKey
    
    New-AzStorageContainer -Name images -Context $blobStorageContext
    New-AzStorageContainer -Name thumbnails -Permission Container -Context $blobStorageContext
    
    New-AzAppServicePlan -ResourceGroupName myRGroup -Name myAppServiceP -Tier "Free"
    

    Create Azure Web App

    New-AzWebApp -ResourceGroupName myRGroup -Name "HarshithaSampleOct" -Location "West US" -AppServicePlan "myAppServiceP"
    

    Get the sample app from the GitHub repository

    az webapp deployment source config --name HarshithaSampleOct --resource-group myRGroup --branch master --manual-integration --repo-url https://github.com/Azure-Samples/storage-blob-upload-from-webapp
    

    Configure web app settings

    az webapp config appsettings set --name HarshithaSampleOct --resource-group myRGroup --settings AzureStorageConfig__AccountName=$blobStorageAccount AzureStorageConfig__ImageContainer=images AzureStorageConfig__ThumbnailContainer=thumbnails AzureStorageConfig__AccountKey=$blobStorageAccountKey
    

    Now browse the URL and upload the image.

    Is there a way I can check my web app configuration settings, including viewing the linked storage account?

    To check the Azure App Configuration Settings, Navigate to Azure Portal => Your Web App => Configuration => Application Settings
    enter image description here

    To view the storage Account in Azure Portal,
    Go to the resource group myRGroup which you have created and click on the Storage Account myblobha

    enter image description here

    In Storage Account => Containers => Click on Images, you can see the uploaded images.

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search