'how to specify network name in app.yaml for asp.net core webapi deployed in Google appengine

I am trying to deploy an asp.net core webapi to google appengine flex. If you don't mention network name in app.yaml then it takes default.

In my case there is no default network. I have to explicitly specify the network name and subnetwork_name in my app.yaml. This project where I am trying to deploy my api in appengine flex is in a shared VPC.This is why I am specifying the complete path, "projects/myorg-npe-232f/global/networks/myorg-shared-network". Please refer the app.yaml below -

runtime: aspnetcore
env: flex
service: default
api_version: 1.1
network:
    name: projects/myorg-npe-232f/global/networks/myorg-shared-network
    subnetwork_name: myorg-exxc-bbdf-subnet-central

I am getting the below error -

Unable to assign value 'projects/myorg-npe-232f/global/networks/myorg-shared-network' to attribute 'name':

value 'projects/myorg-npe-232f/global/networks/myorg-shared-network' for name does not match expression '^(?:^[a-z]([a-z\d-]{0,61}[a-z\d])?$)$' in app.yaml


Solution 1:[1]

As explained in the documentation here:

In a service project, App Engine Flexible resources cannot participate in Shared VPC.

You may want to consider VPC Peering instead if it fits your use case.

Solution 2:[2]

Once the firewall rule and proper permissions are set up, can be deployed either a new or an existing of App Engine flexible ENV service into Shared VPC network, check the parameters in the manifest file:

network:
  name: projects/HOST_PROJECT_ID/global/networks/NETWORK_NAME
  subnetwork_name: SUBNETWORK_NAME

Solution 3:[3]

If you are using AppEngine flex, you can use the same settings.

However, make sure the vpc subnet exists, permissions and the firewall rule setup, I was getting the exact same error when I did not provide subnetwork_name.

Re: https://cloud.google.com/appengine/docs/flexible/dotnet/using-shared-vpc

network:
  name: projects/project-id/global/networks/myorg-shared-vpc
  session_affinity: true
  subnetwork_name: mycompany-develop-us-central1

Another update: Found this same issue with a co-worker, fixed it by updating the cloud commandline client.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 LundinCast
Solution 2 Tiago Medici
Solution 3