{"id":"0827c8ac-766b-4e00-aade-0269d1d4bf07","shortId":"HLU2dE","kind":"skill","title":"azure-messaging-webpubsubservice-py","tagline":"Azure Web PubSub Service SDK for Python. Use for real-time messaging, WebSocket connections, and pub/sub patterns.","description":"# Azure Web PubSub Service SDK for Python\n\nReal-time messaging with WebSocket connections at scale.\n\n## Installation\n\n```bash\n# Service SDK (server-side)\npip install azure-messaging-webpubsubservice\n\n# Client SDK (for Python WebSocket clients)\npip install azure-messaging-webpubsubclient\n```\n\n## Environment Variables\n\n```bash\nAZURE_WEBPUBSUB_CONNECTION_STRING=Endpoint=https://<name>.webpubsub.azure.com;AccessKey=...\nAZURE_WEBPUBSUB_HUB=my-hub\n```\n\n## Service Client (Server-Side)\n\n### Authentication\n\n```python\nfrom azure.messaging.webpubsubservice import WebPubSubServiceClient\n\n# Connection string\nclient = WebPubSubServiceClient.from_connection_string(\n    connection_string=os.environ[\"AZURE_WEBPUBSUB_CONNECTION_STRING\"],\n    hub=\"my-hub\"\n)\n\n# Entra ID\nfrom azure.identity import DefaultAzureCredential\n\nclient = WebPubSubServiceClient(\n    endpoint=\"https://<name>.webpubsub.azure.com\",\n    hub=\"my-hub\",\n    credential=DefaultAzureCredential()\n)\n```\n\n### Generate Client Access Token\n\n```python\n# Token for anonymous user\ntoken = client.get_client_access_token()\nprint(f\"URL: {token['url']}\")\n\n# Token with user ID\ntoken = client.get_client_access_token(\n    user_id=\"user123\",\n    roles=[\"webpubsub.sendToGroup\", \"webpubsub.joinLeaveGroup\"]\n)\n\n# Token with groups\ntoken = client.get_client_access_token(\n    user_id=\"user123\",\n    groups=[\"group1\", \"group2\"]\n)\n```\n\n### Send to All Clients\n\n```python\n# Send text\nclient.send_to_all(message=\"Hello everyone!\", content_type=\"text/plain\")\n\n# Send JSON\nclient.send_to_all(\n    message={\"type\": \"notification\", \"data\": \"Hello\"},\n    content_type=\"application/json\"\n)\n```\n\n### Send to User\n\n```python\nclient.send_to_user(\n    user_id=\"user123\",\n    message=\"Hello user!\",\n    content_type=\"text/plain\"\n)\n```\n\n### Send to Group\n\n```python\nclient.send_to_group(\n    group=\"my-group\",\n    message=\"Hello group!\",\n    content_type=\"text/plain\"\n)\n```\n\n### Send to Connection\n\n```python\nclient.send_to_connection(\n    connection_id=\"abc123\",\n    message=\"Hello connection!\",\n    content_type=\"text/plain\"\n)\n```\n\n### Group Management\n\n```python\n# Add user to group\nclient.add_user_to_group(group=\"my-group\", user_id=\"user123\")\n\n# Remove user from group\nclient.remove_user_from_group(group=\"my-group\", user_id=\"user123\")\n\n# Add connection to group\nclient.add_connection_to_group(group=\"my-group\", connection_id=\"abc123\")\n\n# Remove connection from group\nclient.remove_connection_from_group(group=\"my-group\", connection_id=\"abc123\")\n```\n\n### Connection Management\n\n```python\n# Check if connection exists\nexists = client.connection_exists(connection_id=\"abc123\")\n\n# Check if user has connections\nexists = client.user_exists(user_id=\"user123\")\n\n# Check if group has connections\nexists = client.group_exists(group=\"my-group\")\n\n# Close connection\nclient.close_connection(connection_id=\"abc123\", reason=\"Session ended\")\n\n# Close all connections for user\nclient.close_all_connections(user_id=\"user123\")\n```\n\n### Grant/Revoke Permissions\n\n```python\nfrom azure.messaging.webpubsubservice import WebPubSubServiceClient\n\n# Grant permission\nclient.grant_permission(\n    permission=\"joinLeaveGroup\",\n    connection_id=\"abc123\",\n    target_name=\"my-group\"\n)\n\n# Revoke permission\nclient.revoke_permission(\n    permission=\"joinLeaveGroup\",\n    connection_id=\"abc123\",\n    target_name=\"my-group\"\n)\n\n# Check permission\nhas_permission = client.check_permission(\n    permission=\"joinLeaveGroup\",\n    connection_id=\"abc123\",\n    target_name=\"my-group\"\n)\n```\n\n## Client SDK (Python WebSocket Client)\n\n```python\nfrom azure.messaging.webpubsubclient import WebPubSubClient\n\nclient = WebPubSubClient(credential=token[\"url\"])\n\n# Event handlers\n@client.on(\"connected\")\ndef on_connected(e):\n    print(f\"Connected: {e.connection_id}\")\n\n@client.on(\"server-message\")\ndef on_message(e):\n    print(f\"Message: {e.data}\")\n\n@client.on(\"group-message\")\ndef on_group_message(e):\n    print(f\"Group {e.group}: {e.data}\")\n\n# Connect and send\nclient.open()\nclient.send_to_group(\"my-group\", \"Hello from Python!\")\n```\n\n## Async Service Client\n\n```python\nfrom azure.messaging.webpubsubservice.aio import WebPubSubServiceClient\nfrom azure.identity.aio import DefaultAzureCredential\n\nasync def broadcast():\n    credential = DefaultAzureCredential()\n    client = WebPubSubServiceClient(\n        endpoint=\"https://<name>.webpubsub.azure.com\",\n        hub=\"my-hub\",\n        credential=credential\n    )\n    \n    await client.send_to_all(\"Hello async!\", content_type=\"text/plain\")\n    \n    await client.close()\n    await credential.close()\n```\n\n## Client Operations\n\n| Operation | Description |\n|-----------|-------------|\n| `get_client_access_token` | Generate WebSocket connection URL |\n| `send_to_all` | Broadcast to all connections |\n| `send_to_user` | Send to specific user |\n| `send_to_group` | Send to group members |\n| `send_to_connection` | Send to specific connection |\n| `add_user_to_group` | Add user to group |\n| `remove_user_from_group` | Remove user from group |\n| `close_connection` | Disconnect client |\n| `connection_exists` | Check connection status |\n\n## Best Practices\n\n1. **Use roles** to limit client permissions\n2. **Use groups** for targeted messaging\n3. **Generate short-lived tokens** for security\n4. **Use user IDs** to send to users across connections\n5. **Handle reconnection** in client applications\n6. **Use JSON** content type for structured data\n7. **Close connections** gracefully with reasons\n\n## When to Use\nThis skill is applicable to execute the workflow or actions described in the overview.\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.","tags":["azure","messaging","webpubsubservice","antigravity","awesome","skills","sickn33","agent-skills","agentic-skills","ai-agent-skills","ai-agents","ai-coding"],"capabilities":["skill","source-sickn33","skill-azure-messaging-webpubsubservice-py","topic-agent-skills","topic-agentic-skills","topic-ai-agent-skills","topic-ai-agents","topic-ai-coding","topic-ai-workflows","topic-antigravity","topic-antigravity-skills","topic-claude-code","topic-claude-code-skills","topic-codex-cli","topic-codex-skills"],"categories":["antigravity-awesome-skills"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/sickn33/antigravity-awesome-skills/azure-messaging-webpubsubservice-py","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add sickn33/antigravity-awesome-skills","source_repo":"https://github.com/sickn33/antigravity-awesome-skills","install_from":"skills.sh"}},"qualityScore":"0.700","qualityRationale":"deterministic score 0.70 from registry signals: · indexed on github topic:agent-skills · 34928 github stars · SKILL.md body (5,844 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-04-24T18:50:31.599Z","embedding":null,"createdAt":"2026-04-18T21:32:39.585Z","updatedAt":"2026-04-24T18:50:31.599Z","lastSeenAt":"2026-04-24T18:50:31.599Z","tsv":"'1':596 '2':603 '3':609 '4':617 '5':627 '6':633 '7':641 'abc123':244,298,313,326,356,386,400,416 'access':127,137,151,165,535 'accesskey':74 'across':625 'action':659 'add':254,284,569,573 'anonym':132 'applic':632,653 'application/json':201 'ask':697 'async':489,501,521 'authent':86 'await':516,525,527 'azur':2,6,24,50,62,68,75,101 'azure-messaging-webpubsubcli':61 'azure-messaging-webpubsubservic':49 'azure-messaging-webpubsubservice-pi':1 'azure.identity':112 'azure.identity.aio':498 'azure.messaging.webpubsubclient':429 'azure.messaging.webpubsubservice':89,375 'azure.messaging.webpubsubservice.aio':494 'bash':41,67 'best':594 'boundari':705 'broadcast':503,544 'check':317,327,338,406,591 'clarif':699 'clear':672 'client':53,58,82,94,115,126,136,150,164,176,422,426,432,491,506,529,534,588,601,631 'client.add':258,288 'client.check':410 'client.close':352,365,526 'client.connection':322 'client.get':135,149,163 'client.grant':380 'client.group':344 'client.on':439,450,462 'client.open':479 'client.remove':273,303 'client.revoke':394 'client.send':180,191,206,222,239,480,517 'client.user':333 'close':350,360,585,642 'connect':20,37,70,92,96,98,103,237,241,242,247,285,289,296,300,304,311,314,319,324,331,342,351,353,354,362,367,384,398,414,440,443,447,476,539,547,564,568,586,589,592,626,643 'content':186,199,215,232,248,522,636 'credenti':123,434,504,514,515 'credential.close':528 'criteria':708 'data':197,640 'def':441,454,466,502 'defaultazurecredenti':114,124,500,505 'describ':660,676 'descript':532 'disconnect':587 'e':444,457,470 'e.connection':448 'e.data':461,475 'e.group':474 'end':359 'endpoint':72,117,508 'entra':109 'environ':65,688 'environment-specif':687 'event':437 'everyon':185 'execut':655 'exist':320,321,323,332,334,343,345,590 'expert':693 'f':140,446,459,472 'generat':125,537,610 'get':533 'grace':644 'grant':378 'grant/revoke':371 'group':161,170,220,224,225,228,231,251,257,261,262,265,272,276,277,280,287,291,292,295,302,306,307,310,340,346,349,391,405,421,464,468,473,482,485,557,560,572,576,580,584,605 'group-messag':463 'group1':171 'group2':172 'handl':628 'handler':438 'hello':184,198,213,230,246,486,520 'hub':77,80,105,108,119,122,510,513 'id':110,147,154,168,210,243,267,282,297,312,325,336,355,369,385,399,415,449,620 'import':90,113,376,430,495,499 'input':702 'instal':40,48,60 'joinleavegroup':383,397,413 'json':190,635 'limit':600,664 'live':613 'manag':252,315 'match':673 'member':561 'messag':3,18,34,51,63,183,194,212,229,245,453,456,460,465,469,608 'miss':710 'my-group':226,263,278,293,308,347,389,403,419,483 'my-hub':78,106,120,511 'name':388,402,418 'notif':196 'oper':530,531 'os.environ':100 'output':682 'overview':663 'pattern':23 'permiss':372,379,381,382,393,395,396,407,409,411,412,602,703 'pip':47,59 'practic':595 'print':139,445,458,471 'pub/sub':22 'pubsub':8,26 'py':5 'python':12,30,56,87,129,177,205,221,238,253,316,373,424,427,488,492 'real':16,32 'real-tim':15,31 'reason':357,646 'reconnect':629 'remov':269,299,577,581 'requir':701 'review':694 'revok':392 'role':156,598 'safeti':704 'scale':39 'scope':675 'sdk':10,28,43,54,423 'secur':616 'send':173,178,189,202,218,235,478,541,548,551,555,558,562,565,622 'server':45,84,452 'server-messag':451 'server-sid':44,83 'servic':9,27,42,81,490 'session':358 'short':612 'short-liv':611 'side':46,85 'skill':651,667 'skill-azure-messaging-webpubsubservice-py' 'source-sickn33' 'specif':553,567,689 'status':593 'stop':695 'string':71,93,97,99,104 'structur':639 'substitut':685 'success':707 'target':387,401,417,607 'task':671 'test':691 'text':179 'text/plain':188,217,234,250,524 'time':17,33 'token':128,130,134,138,142,144,148,152,159,162,166,435,536,614 'topic-agent-skills' 'topic-agentic-skills' 'topic-ai-agent-skills' 'topic-ai-agents' 'topic-ai-coding' 'topic-ai-workflows' 'topic-antigravity' 'topic-antigravity-skills' 'topic-claude-code' 'topic-claude-code-skills' 'topic-codex-cli' 'topic-codex-skills' 'treat':680 'type':187,195,200,216,233,249,523,637 'url':141,143,436,540 'use':13,597,604,618,634,649,665 'user':133,146,153,167,204,208,209,214,255,259,266,270,274,281,329,335,364,368,550,554,570,574,578,582,619,624 'user123':155,169,211,268,283,337,370 'valid':690 'variabl':66 'web':7,25 'webpubsub':69,76,102 'webpubsub.azure.com':73,118,509 'webpubsub.joinleavegroup':158 'webpubsub.sendtogroup':157 'webpubsubcli':64,431,433 'webpubsubservic':4,52 'webpubsubservicecli':91,116,377,496,507 'webpubsubserviceclient.from':95 'websocket':19,36,57,425,538 'workflow':657","prices":[{"id":"c7bc98bd-5ddb-497f-a991-1d11330b9ad5","listingId":"0827c8ac-766b-4e00-aade-0269d1d4bf07","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"sickn33","category":"antigravity-awesome-skills","install_from":"skills.sh"},"createdAt":"2026-04-18T21:32:39.585Z"}],"sources":[{"listingId":"0827c8ac-766b-4e00-aade-0269d1d4bf07","source":"github","sourceId":"sickn33/antigravity-awesome-skills/azure-messaging-webpubsubservice-py","sourceUrl":"https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/azure-messaging-webpubsubservice-py","isPrimary":false,"firstSeenAt":"2026-04-18T21:32:39.585Z","lastSeenAt":"2026-04-24T18:50:31.599Z"}],"details":{"listingId":"0827c8ac-766b-4e00-aade-0269d1d4bf07","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"sickn33","slug":"azure-messaging-webpubsubservice-py","github":{"repo":"sickn33/antigravity-awesome-skills","stars":34928,"topics":["agent-skills","agentic-skills","ai-agent-skills","ai-agents","ai-coding","ai-workflows","antigravity","antigravity-skills","claude-code","claude-code-skills","codex-cli","codex-skills","cursor","cursor-skills","developer-tools","gemini-cli","gemini-skills","kiro","mcp","skill-library"],"license":"mit","html_url":"https://github.com/sickn33/antigravity-awesome-skills","pushed_at":"2026-04-24T06:41:17Z","description":"Installable GitHub library of 1,400+ agentic skills for Claude Code, Cursor, Codex CLI, Gemini CLI, Antigravity, and more. Includes installer CLI, bundles, workflows, and official/community skill collections.","skill_md_sha":"17f91a9ade07ac886210e61e6652372216a6b8a4","skill_md_path":"skills/azure-messaging-webpubsubservice-py/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/azure-messaging-webpubsubservice-py"},"layout":"multi","source":"github","category":"antigravity-awesome-skills","frontmatter":{"name":"azure-messaging-webpubsubservice-py","description":"Azure Web PubSub Service SDK for Python. Use for real-time messaging, WebSocket connections, and pub/sub patterns."},"skills_sh_url":"https://skills.sh/sickn33/antigravity-awesome-skills/azure-messaging-webpubsubservice-py"},"updatedAt":"2026-04-24T18:50:31.599Z"}}