I've started a cosmos db in my docker on the windows machine, used Linux docker image.
docker run \
--publish 8081:8081 \
--publish 10250-10255:10250-10255 \
--name linux-emulator \
--detach \
mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:latest
I can access web portal through the https://localhost:8081/_explorer/index.html
However when I run my script, I get following error:
raise exceptions.CosmosHttpResponseError(message=data, response=response)
azure.cosmos.exceptions.CosmosHttpResponseError: (Forbidden) Request originated from IP 167.16.252.82 through public internet. This is blocked by your Cosmos DB account firewall settings. More info: https://aka.ms/cosmosdb-tsg-forbidden
How do I configure firewall setting for the local emaulator running locally.
Here is a simple script i'm trying to run
from azure.cosmos import CosmosClient, PartitionKey
print('Connecting to Cosmos DB...')
client = CosmosClient(
url="https://127.0.0.1:8081/",
credential=(
"C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="
),
)
print('creating database')
database = client.create_database_if_not_exists(
id="cosmicworks",
offer_throughput=400,
)
print('creating container')
container = database.create_container_if_not_exists(
id="products",
partition_key=PartitionKey(
path="/id",
),
)
print('setting item')
item = {"id": "68719518371", "name": "Kiama classic surfboard"}
container.upsert_item(item)