Error: The specifed resource name contains invalid characters.

Kim Strasser 1,321 Reputation points
2025-03-04T14:57:28.3033333+00:00

I always get this error when I choose Azure Functions: Create Function App in Azure and

3:29:41 PM: Creating resource group "newazurefunctionappdistr" in location "East US"... 3:29:42 PM: Successfully created resource group "newazurefunctionappdistr". 3:29:42 PM: Ensuring App Service plan "FLEX-Newazurefunctionappdistribution-2c98" exists... 3:29:42 PM: Creating App Service plan "FLEX-Newazurefunctionappdistribution-2c98"... 3:29:53 PM: Successfully created App Service plan "FLEX-Newazurefunctionappdistribution-2c98". 3:29:53 PM: Creating storage account "newazurefunctionappdistr" in location "East US" with sku "Standard_LRS"... 3:30:15 PM: Successfully created storage account "newazurefunctionappdistr". 3:30:16 PM: Creating new Log Analytics workspace... 3:30:16 PM: Successfully created new Log Analytics workspace "workspace-newazurefunctionappdistr". 3:30:20 PM: Verifying that Application Insights is available for this location... 3:30:21 PM: Creating Application Insights resource "newazurefunctionappdistr"... 3:30:24 PM: Successfully created Application Insights resource "newazurefunctionappdistr". 3:30:24 PM: Creating new function app "Newazurefunctionappdistribution"... 3:30:53 PM: Error: The specifed resource name contains invalid characters. RequestId:9e2783b0-c01e-0063-3912-8d988f000000 Time:2025-03-04T14:30:53.8298677Z

My csproj file in Visual Studio Cpde looks like this:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.1" />
    <PackageReference Include="PlayFabAllSDK" Version="1.150.230403" />
  </ItemGroup>
  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
</Project>

Which settings should I choose when I try to create my function app?

Screenshot 2025-03-04 155616

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,911 questions
0 comments No comments
{count} votes

Accepted answer
  1. Sai Prabhu Naveen Parimi 2,265 Reputation points Microsoft External Staff Moderator
    2025-03-10T05:23:13.9+00:00

    Kim Strasser

    Thanks for the update! Glad to see you were able to resolve your issue. Thanks for posting your solution so that others experiencing the same thing can easily reference this.

    Since the Microsoft Q&A community has a policy that the question author cannot accept their own answer, they can only accept answers by others, I'll repost your solution in case you'd like to Accept the answer.

    Issue :
    Encountered an error while creating an Azure Function App using CLI or Visual Studio Code:

    "The specified resource name contains invalid characters."

    Despite trying different function app names and selecting .NET 8 Isolated, the issue persisted.

    Resolution:

    The issue was resolved by creating the Azure Function App directly through the Azure Portal instead of using CLI or VS Code. This ensured the resource name followed Azure’s naming conventions and avoided conflicts with existing resources.

    Essential Insights :

    • Creating the app through the Azure Portal helps validate names and avoid conflicts.
    • Function App names must follow Azure’s naming rules, which allow only lowercase letters, numbers, and hyphens.
    • If deployment through the CLI or VS Code fails, try using the Azure Portal for manual creation.

    Hope this helps others facing similar issues!

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Jose Benjamin Solis Nolasco 3,506 Reputation points
    2025-03-04T15:09:44.0966667+00:00

    Hello @Kim Strasser

    It looks like the error you're encountering is due to invalid characters in the resource name. Azure has specific naming rules for resources, and violating these rules can cause errors during deployment. Here are some common guidelines for naming Azure resources:

    1. Resource Group Names: Can contain alphanumeric characters, periods, underscores, hyphens, and parentheses. They must be between 1 and 90 characters in length.

    App Service Plan Names: Can contain alphanumeric characters and hyphens. They must be between 1 and 40 characters in length.

    Storage Account Names: Must be between 3 and 24 characters in length and can contain only lowercase letters and numbers.

    Function App Names: Must be between 1 and 60 characters in length and can contain alphanumeric characters and hyphens. They must be unique within Azure.

    In your case, it seems like the function app name Newazurefunctionappdistribution might be causing the issue. Here are a few things to check:

    Ensure that the name does not exceed 60 characters.

    Avoid using special characters or spaces in the name.

    Make sure the name is unique within Azure.

    You can find more information on naming rules and conventions for Azure resourcesIt looks like the error you're encountering is due to invalid characters in the resource name. Azure has specific naming rules for resources, and violating these rules can cause errors during deployment. Here are some common guidelines for naming Azure resources:

    Resource Group Names: Can contain alphanumeric characters, periods, underscores, hyphens, and parentheses. They must be between 1 and 90 characters in length.

    App Service Plan Names: Can contain alphanumeric characters and hyphens. They must be between 1 and 40 characters in length.

    Storage Account Names: Must be between 3 and 24 characters in length and can contain only lowercase letters and numbers.

    Function App Names: Must be between 1 and 60 characters in length and can contain alphanumeric characters and hyphens. They must be unique within Azure.

    In your case, it seems like the function app name Newazurefunctionappdistribution might be causing the issue. Here are a few things to check:

    Ensure that the name does not exceed 60 characters.

    Avoid using special characters or spaces in the name.

    Make sure the name is unique within Azure.

    You can find more information on naming rules and conventions for Azure resources https://learn.microsoft.com/en-us/answers/questions/483876/azure-functions-runtime-error

    And your last question about which select depends on your requirements:

    .NET 8 Isolated (Recommended for most cases)

    • It's a stable, long-term support (LTS) version, meaning Microsoft will provide support and updates for a longer period.
      • Ideal for production applications that need long-term reliability.
      .NET 9 Isolated
      - It's a preview or short-term support (STS) version.
      
         - Suitable for testing new features but not recommended for production environments.
      

    If you're deploying a function app for production, go with .NET 8 Isolated. If you're experimenting with the latest features and can handle potential instability, then .NET 9 Isolated might be an option.

    If you found it helpful, could you kindly click the “Accept Answer and upvote” on the post.

    If you have any further queries, please let us know we are glad to help you.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.